1.引入jar
<dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.0.13</version> </dependency>
2.增加logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> </layout> </appender> <logger name="com.base22" level="TRACE"/> <root level="debug"> <appender-ref ref="STDOUT" /> </root> </configuration>
root level="debug"定义日志级别,appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"定义输出到控制台