<?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 - %msg%n <!-- 控制台打印日志文件体 时间-信息 -->
</pattern>
</layout>
</appender>
<!-- info日志 -->
<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>
<encoder>
<pattern>
%msg%n
</pattern>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 设置info日志路径 -->
<fileNamePattern>E:\\IntelliJ IDEA\\logback\\info.%d.log</fileNamePattern>
</rollingPolicy>
</appender>
<!-- error日志 -->
<appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤日志 -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>
%msg%n
</pattern>
</encoder>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 设置error日志路径 -->
<fileNamePattern>E:\\IntelliJ IDEA\\logback\\error.%d.log</fileNamePattern>
</rollingPolicy>
</appender>
<!-- 设置默认日志级别为INFO -->
<root level="info">
<appender-ref ref="consoleLog"/>
<appender-ref ref="fileInfoLog"/>
<appender-ref ref="fileErrorLog"/>
</root>
</configuration>