- 非常自然的实现了SLF4J
- logback 需要包: slf4j-api,logback-core,logback-classic
- log4j 需要包:slf4j-api,slf4j-log4j12,log4j
一、配置
1、pom.xml
<properties>
<slf4j.version>1.7.2</slf4j.version>
<logback.version>1.2.17</logback.version>
</properties>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
2、logback.xml
一般在 src/main/resources 下。
logback的具体细节 -> 点这里
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>