<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG" monitorInterval="60">


    <Properties>
        <!--自定义一些常量，之后使用${变量名}引用-->
        <Property name="logFilePath">logs</Property>
    </Properties>


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

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

        <RollingFile name="RollingFileInfo" fileName="${logFilePath}/info.log"
                     filePattern="${logFilePath}/$${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="20MB"/>
            </Policies>
            <!--文件数量的设置-->
            <DefaultRolloverStrategy max="50"/>
        </RollingFile>

        <RollingFile name="RollingFileWarn" fileName="${logFilePath}/warn.log"
                     filePattern="${logFilePath}/$${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="20MB"/>
            </Policies>
            <!--文件数量的设置-->
            <DefaultRolloverStrategy max="50"/>
        </RollingFile>

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

    <Loggers>
        <logger name="org.springframework" level="INFO"></logger>
        <logger name="com.netflix" level="INFO"></logger>
        <logger name="org.apache" level="INFO"></logger>
        <logger name="org.mybatis" level="INFO"></logger>
        <logger name="com.alibaba.nacos" level="WARN"></logger>
        <Root level="DEBUG">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="RollingFileInfo"/>
            <AppenderRef ref="RollingFileWarn"/>
            <AppenderRef ref="RollingFileError"/>
        </Root>

    </Loggers>
</Configuration>
