idea安装lombok
pom新增包
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency>
配置log ( logback-spring.xml )
<?xml version="1.0" encoding="UTF-8" ?> <configuration> <!--ch.qos.logback.core.ConsoleAppender 是 logback 类的完整路径--> <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> %d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n </pattern> </layout> </appender> <!--RollingFileAppender 可以做到每天输出一个日志文件--> <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!--LevelFilter --> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>ERROR</level> <!--匹配则禁止--> <onMatch>DENY</onMatch> <!--不匹配则应用--> <onMismatch>ACCEPT</onMismatch> </filter> <encoder> <pattern> %d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n </pattern> </encoder> <!-- 滚动策略 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!--输出路径--> <fileNamePattern>${user.dir}\logger\info.%d.log</fileNamePattern> </rollingPolicy> </appender> <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!--ThresholdFilter 根据范围过滤,即大于等于 error 的日志都记录--> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>ERROR</level> </filter> <encoder> <pattern> %d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n </pattern> </encoder> <!-- 滚动策略 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${user.dir}\logger\error.%d.log</fileNamePattern> </rollingPolicy> </appender> <root level="info"> <appender-ref ref="consoleLog"></appender-ref> <appender-ref ref="fileInfoLog"></appender-ref> <appender-ref ref="fileErrorLog"></appender-ref> </root> </configuration>
标签:m%,log,项目,spring,dd,HH,yyyy,slf4j From: https://www.cnblogs.com/zhougongjin/p/17097487.html