<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="log_path" value="/home/ww/test/tomcat-test/logs/"/>

    <!-- 打印在标准控制台 -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <!--格式化输出：%d：时间，%thread：线程名，%-5level：级别从左显示5个字符宽度,
            %logger{50}：输出日志的类, 50代表包名加类名的总长度限制, %M 方法名 %L 行号 %msg：日志消息，%n是换行符-->
            <pattern>%d{MM-dd HH:mm:ss} [%thread] %-5level %logger{30} %M %L - %msg%n</pattern>
        </encoder>

        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>DEBUG</level>
        </filter>
    </appender>

    <!-- 错误信息 -->
    <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <Encoding>UTF-8</Encoding>
        <encoder>
            <pattern>%d{MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{30} %M - %msg%n%L</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_path}error.%d{MM-dd}.log</fileNamePattern>
        </rollingPolicy>
    </appender>

    <!-- 屏蔽框架输出 -->
    <logger name="org.slf4j" level="ERROR"/>
    <logger name="org.springframework" level="ERROR"/>
    <logger name="io.swagger" level="ERROR"/>
    <logger name="ch.qos.logback" level="OFF"/>
    <logger name="springfox.documentation" level="ERROR"/>

    <!-- 所有的日志同时应用“STDOUT”和“EROOR”的策略 -->
    <root>
        <level value="DEBUG"/>
        <!--<appender-ref ref="TPM"/>-->
        <appender-ref ref="ERROR"/>
        <appender-ref ref="STDOUT"/>
    </root>

</configuration>