Slf4j + Logback
logback 官方地址:https://logback.qos.ch/
- Logback实现了Slf4j API
- 除了Logback-classic .jar之外,Logback-classic模块还需要在类路径上存在slf4j-api.jar和logback-core.jar。
logback环境搭建:https://logback.qos.ch/setup.html
- 从1.3.x版开始, logback需要Java 9来构建。但是,它可以在Java 8或更高版本上运行。Logback 1.2.x 版本,需要Java 6以上
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.0-alpha13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
<scope>test</scope>
</dependency>
日志打印在代码中使用
private Logger log = LoggerFactory.getLogger(xxx.class);
logback配置参考:
https://github.com/carlspring/logback-configuration/edit/master/logback-configuration-core/src/test/resources/logback.xml
https://www.cnblogs.com/gavincoder/p/10091757.html
|