logBack-spring.xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
</layout>
</appender>
<appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>DENY</onMatch>
<onMismatch>ACCEPT</onMismatch>
</filter>
<!--正在记录的日志-->
<file>/var/log/aLog/info.log</file>
<encoder>
<charset>utf-8</charset>
<pattern>===%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--归档的日志文件路径-->
<fileNamePattern>/var/log/aLog/info.%d{yyyy-MM-dd-HH}.log</fileNamePattern>
<!--最多保留90天日志-->
<maxHistory>90</maxHistory>
</rollingPolicy>
</appender>
<appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<!--正在记录的ERROR级别日志-->
<file>/var/log/aLog/error.log</file>
<encoder>
<charset>utf-8</charset>
<pattern>===%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>/var/log/aLog/error.%d{yyyy-MM-dd-HH}.log</fileNamePattern>
<!--最多保留90天日志-->
<maxHistory>90</maxHistory>
</rollingPolicy>
</appender>
<root level="info">
<appender-ref ref="consoleLog"/>
<appender-ref ref="fileInfoLog"/>
<appender-ref ref="fileErrorLog"/>
</root>
</configuration>