为什么logback配置没有问题可是打印不出老师那样的一堆DEBUG信息呢?
表示从头到尾都跟老师打的一样呀,求大神解答呀!
表示从头到尾都跟老师打的一样呀,求大神解答呀!
2018-07-27
maven的porm.xml需要以下几个依赖
<!-- sl4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
</dependency>
logback.xml文件放到指定的文件夹目录下src/main/resources
<?xml version="1.0" encoding="UTF-8"?>
<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>
测试类当中像老师那样调用即可
private final Logger logger = LoggerFactory.getLogger(this.getClass());
logger.info("s={}", s);
举报