<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">

    <Properties>
        <Property name="commonLevel" value="${sys:log.commonLevel}"/>
    </Properties>

    <Appenders>
        <!-- 控制台 日志 -->
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS}| %level | %X{TRACE_ID} - %X{CALLER} | %m | %l%n"/>
        </Console>
        <!-- debug 日志 -->
        <RollingFile name="DEBUG_APPERDER" fileName="./logs/debug/debug.log"
                     filePattern="./logs/debug/debug-%d{yyyy.MM.dd.HH}-%i.log">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS}| %level | %X{TRACE_ID} - %X{CALLER} | %m | %l%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1"/>
                <SizeBasedTriggeringPolicy size="100MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10">
                <Delete basePath="./logs/debug" maxDepth="1">
                    <IfFileName glob="debug-*.log"/>
                    <IfLastModified age="24H"/>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <!-- 接口日志 -->
        <RollingFile name="INTERFACE_APPENDER" fileName="./logs/interface/interface.log"
                     filePattern="./logs/interface/interface-%d{yyyy.MM.dd.HH}-%i.log">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS}| %level | %X{TRACE_ID} - %X{CALLER} | %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1"/>
                <SizeBasedTriggeringPolicy size="100MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10">
                <Delete basePath="./logs/interface" maxDepth="1">
                    <IfFileName glob="interface-*.log"/>
                    <IfLastModified age="24H"/>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
    </Appenders>

    <Loggers>
        <Logger name="cn.com.qmth" level="${commonLevel}" additivity="false">
            <AppenderRef ref="DEBUG_APPERDER"/>
            <AppenderRef ref="Console"/>
        </Logger>

        <Logger name="INTERFACE_LOGGER" level="INFO" additivity="false">
            <AppenderRef ref="INTERFACE_APPENDER"/>
            <AppenderRef ref="Console"/>
        </Logger>

        <logger name="org.docx4j.model.properties.run.FontSize" level="OFF"/>
        <Logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="${commonLevel}"/>
        <Logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="${commonLevel}"/>
        <Logger name="org.hibernate.SQL" level="${commonLevel}"/>
        <Logger name="org.hibernate.type" level="${commonLevel}"/>
        <Logger name="org.hibernate.engine.QueryParameters" level="${commonLevel}"/>
        <Logger name="org.hibernate.engine.query.HQLQueryPlan" level="${commonLevel}"/>

        <logger name="org.springframework" level="WARN"/>
        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="WARN"/>
        <logger name="org.springframework.data.mongodb" level="WARN"/>
        <logger name="com.netflix" level="WARN"/>
        <logger name="com.netflix.discovery" level="WARN"/>
        <logger name="springfox.documentation" level="WARN"/>
        <logger name="cn.afterturn.easypoi" level="WARN"/>
        <logger name="org.apache" level="WARN"/>
        <logger name="org.docx4j" level="ERROR"/>

        <Root level="INFO">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="DEBUG_APPERDER"/>
        </Root>
    </Loggers>

</Configuration>