<?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="fileInLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!--过滤日志，error级别高，LevelFilter-->
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>DENY</onMatch>
            <onMismatch>ACCEPT</onMismatch>
        </filter>
        <encoder>
            <pattern>
                %d - %msg%n
            </pattern>
        </encoder>
        <!--滚动策略 每天输出1个日志 按照时间滚动-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--添加路径-->
            <fileNamePattern>./log/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>
                %d - %msg%n
            </pattern>
        </encoder>
        <!--滚动策略-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--添加路径-->
            <fileNamePattern>./log/error.%d.log</fileNamePattern>
        </rollingPolicy>
    </appender>

    <!--指明配置项用在哪-->
    <root level="INFO">
        <!--引用日志存储器-->
        <appender-ref ref="consoleLog"/>
        <appender-ref ref="fileInLog"/>
        <appender-ref ref="fileErrorLog"/>
    </root>
</configuration>