pom依赖
<!-- slf4j-->
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!--logback-->
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/ssm.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/ssm%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<property name="log.pattern"
value="%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method :%L -%msg%n"/>
<property name="log.colorPattern"
value="%d{yyyy-MM-dd HH:mm:ss} | %highlight(%-5level) | %yellow(%thread) | %green(%logger{56}.%method :%L) | %msg%n"/>
<!--控制台输出 -->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--<Pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method :%L -%msg%n</Pattern> -->
<Pattern>${log.colorPattern}</Pattern>
</encoder>
</appender>
<!-- project default level -->
<logger name="com.xwy" level="DEBUG" />
<!--log4jdbc -->
<logger name="jdbc.sqltiming" level="INFO"/>
<logger name="dao" level="DEBUG" >
<appender-ref ref="stdout" />
</logger>
<root level="INFO">
<appender-ref ref="stdout" />
</root>
</configuration>