<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE" value="20MB"/>
    <!-- 导入安心筑全局日志配置 -->
    <include resource="logback/logback-axzo.xml"/>
    <!-- 输出到error -->
    <appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/ERROR/error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <!--日志文件输出的文件名-->
            <fileNamePattern>${LOG_PATH}/ERROR/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <!--日志文件最大的大小-->
            <maxFileSize>50MB</maxFileSize>
            <!--日志文件保留天数-->
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <encoder>
            <!--格式化输出：%d表示日期，%thread表示线程名，%-5level：级别从左显示5个字符宽度%msg：日志消息，%n是换行符-->
            <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter"><!-- 只打印ERROR日志 -->
            <level>ERROR</level>
        </filter>
    </appender>

    <!-- 输出到error -->
    <appender name="warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/WARN/warn.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <!--日志文件输出的文件名-->
            <fileNamePattern>${LOG_PATH}/WARN/%d{yyyy-MM}/warn.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <!--日志文件最大的大小-->
            <maxFileSize>50MB</maxFileSize>
            <!--日志文件保留天数-->
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <encoder>
            <!--格式化输出：%d表示日期，%thread表示线程名，%-5level：级别从左显示5个字符宽度%msg：日志消息，%n是换行符-->
            <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter"><!-- 只打印ERROR日志 -->
            <level>WARN</level>
        </filter>
    </appender>
    <!-- 覆盖开发环境日志配置 -->
    <springProfile name="local,dev">
        <logger name="cn.axzo" level="DEBUG">
            <appender-ref ref="ASYNC"/>
        </logger>
    </springProfile>
    <springProfile name="dev,test,pre">
        <root level="INFO">
            <appender-ref ref="error"/>
        </root>
    </springProfile>
    <springProfile name="dev,test,pre">
        <root level="INFO">
            <appender-ref ref="warn"/>
        </root>
    </springProfile>
</configuration>
