<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
    <!--定义所有的appender-->
    <Appenders>
        <!--输出控制台的配置-->
        <Console name="Console" target="SYSTEM_OUT">
            <!--日志信息的格式-->
            <PatternLayout pattern="%d{HH:mm:ss:SSS} [%p] %c  %m%n"/>
        </Console>

        <!--输出文件的配置-->
        <File name="log" fileName="C:/logs/test.log" append="false">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %c{36} %L %c %M %msg%n"/>
        </File>

        <RollingFile name="RollingFileInfo" fileName="C:/logs/info.log"
                     filePattern="C:/logs/$${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log">
            <!--只输出level级别以上的信息（onMatch），其他级别的拒绝（onMismatch）-->
            <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss:SSS} [%p] %l %c %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="1MB"/>
            </Policies>
        </RollingFile>

        <RollingFile name="RollingFileWarn" fileName="C:/logs/warn.log"
                     filePattern="C:/logs/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log">
            <ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss:SSS} [%p] %l %c %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="1MB"/>
            </Policies>
            <!--文件数量的设置-->
            <DefaultRolloverStrategy max="20"/>
        </RollingFile>
    </Appenders>

    <Loggers>
        <Root level="DEBUG">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="RollingFileInfo"/>
            <AppenderRef ref="RollingFileWarn"/>
        </Root>

        <Logger name="org.springframework" level="WARN" additivity="false"></Logger>
        <Logger name="org.mybatis" level="WARN" additivity="false"></Logger>
        <Logger name="org.apache.ibatis" level="WARN" additivity="false"></Logger>
        <Logger name="druid.sql.Connection" level="WARN" additivity="false"></Logger>
        <Logger name="druid.sql.Statement" level="WARN" additivity="false"></Logger>
        <Logger name="druid.sql.ResultSet" level="WARN" additivity="false"></Logger>
    </Loggers>
</Configuration>
