<?xml version="1.0" encoding="UTF-8"?>
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
<!--Configuration后面的status，这个用于设置log4j2自身内部的信息输出，可以不设置，当设置成trace时，你会看到log4j2内部各种详细输出-->
<!--monitorInterval：Log4j能够自动检测修改配置 文件和重新配置本身，设置间隔秒数-->
<configuration status="WARN" monitorInterval="30" packages="cn.estsh.impp.framework.boot.log">
    <Properties>
        <Property name="log4j2.level" value="INFO"/>

        <!-- 日志输出格式 -->
        <Property name="info_pattern">[%p] %d{yyyy-MM-dd HH:mm:ss-SSS} %c(%M:%L) 信息:%m%n</Property>
    </Properties>

    <appenders>
        <!-- impp 日志拦截 -->
        <ImppLog4j2Appender name="impp_log">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %t [%c{1.}(%M:%L)] ==>> %msg%xEx"/>
        </ImppLog4j2Appender>

        <!--控制台日志-->
        <console name="console" target="SYSTEM_OUT" follow="true">
            <PatternLayout>
                <Pattern>${info_pattern}</Pattern>
            </PatternLayout>
        </console>

        <!-- xxljob应用调度日志文件-->
        <ImppLog4j2XxlJob name="log_schedule_xxljob_file"
                          filePath="${logFileRootPath}/schedule/xxlJob"
                          append="true" immediateFlush="true" bufferedIO="true" bufferSize="8192"
                          filePattern="${logFileRootPath}/schedule/$${date:yyyy-MM}/task-id-%d{yyyy-MM-dd}-%i.log.gz">
            <PatternLayout pattern="${file_pattern}"/>

            <Filters>
                <ImppScheduleXxlJobFilter onMatch="ACCEPT" onMismatch="DENY"/>
                <!--                <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>-->
            </Filters>

            <!-- 滚动策略 -->
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="1024 MB"/>
            </Policies>

            <!-- 定时删除 -->
            <DefaultRolloverStrategy  max="100">
                <Delete basePath="${logFileRootPath}" maxDepth="3">
                    <IfFileName glob="**/i3pcn**.log.gz">
                        <IfLastModified age="7d"/>
                    </IfFileName>
                    <IfFileName glob="**/schedule/**/**.log">
                        <IfLastModified age="7d"/>
                    </IfFileName>
                </Delete>
            </DefaultRolloverStrategy>
        </ImppLog4j2XxlJob>
    </appenders>

    <loggers>
        <!-- 忽略 Swagger 格式化错误 -->
        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>
        <root level="${log4j2.level}">
            <appender-ref ref="impp_log"/>
            <appender-ref ref="console"/>
            <appender-ref ref="log_schedule_xxljob_file"/>
        </root>
    </loggers>
</configuration>