<?xml version="1.0" encoding="UTF-8"?>
<!--

    开源代码，仅供学习和交流研究使用，商用请联系三丙
    微信：mohan_88888
    抖音：程序员三丙
    付费课程：https://www.bilibili.com/cheese/play/ss942400790

-->
<configuration status="INFO" monitorInterval="30">

    <properties>
        <Property name="LOG_DIR">${LOG_HOME:-./logs/jcpp}</Property>
        <Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss:SSS} [%X{TRACE_ID}] [%t] %p %c{1} %m%n%throwable</Property>
    </properties>

    <Appenders>

        <Console name="CONSOLE" target="SYSTEM_OUT" follow="true">
            <PatternLayout pattern="${LOG_PATTERN}"/>
        </Console>

        <RollingFile name="ROLLING_FILE" fileName="${LOG_DIR}/jcpp-app.log"
                     filePattern="${LOG_DIR}/jcpp-app.%d{yyyy-MM-dd}-%i.log"
                     immediateFlush="false">
            <PatternLayout pattern="${LOG_PATTERN}"/>

            <Policies>
                <SizeBasedTriggeringPolicy size="1G"/>
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>

            <DefaultRolloverStrategy>
                <Delete basePath="${LOG_DIR}" maxDepth="1">
                    <IfFileName glob="*.log"/>
                    <IfAccumulatedFileSize exceeds="10GB"/>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>

    </Appenders>

    <Loggers>

        <logger name="org.springframework" level="INFO" />

        <AsyncRoot level="INFO" includeLocation="true">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="ROLLING_FILE"/>
        </AsyncRoot>

        <AsyncLogger name="sanbing.jcpp" level="INFO" additivity="false" includeLocation="false">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="ROLLING_FILE"/>
        </AsyncLogger>

        <AsyncLogger name="sanbing.jcpp.app" level="${env:APP_LOG_LEVEL:-TRACE}"
                     additivity="false" includeLocation="false">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="ROLLING_FILE"/>
        </AsyncLogger>

        <AsyncLogger name="sanbing.jcpp.protocol" level="${env:PROTOCOLS_LOG_LEVEL:-TRACE}"
                     additivity="false" includeLocation="false">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="ROLLING_FILE"/>
        </AsyncLogger>

    </Loggers>

</configuration>
