<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <properties>
        <property name="logBase">~/</property>
    </properties>

    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout charset="UTF-8" pattern="[%d] [%X{TRACE_ID}] [%-5p] [%t] [%c] - %m%n"/>
        </Console>
        <RollingFile name="AccessFile" fileName="${logBase}/logs/access.log" filePattern="${logBase}/logs/access.%d{yyyy-MM-dd}.log">
            <PatternLayout pattern="[%d] [%X{TRACE_ID}] [%-5p] [%t] [%c] - %m%n"/>
            <Policies>
                <!-- 设置日志文件切分参数 -->
                <OnStartupTriggeringPolicy/>
                <!--设置日志基础文件大小，超过该大小就触发日志文件滚动更新-->
                <SizeBasedTriggeringPolicy size="500 MB"/>
                <!--设置日志文件滚动更新的时间，依赖于文件命名filePattern的设置-->
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy max="100"/>
        </RollingFile>
        <RollingFile name="ErrorFile" fileName="${logBase}/logs/error.log" filePattern="${logBase}/logs/error.%d{yyyy-MM-dd}.log">
            <Filters>
                <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
            </Filters>
            <PatternLayout pattern="[%d] [%X{TRACE_ID}] [error] [%t] [%c] - %m%n"/>
            <TimeBasedTriggeringPolicy/>
        </RollingFile>
    </Appenders>

    <Loggers>
        <Root level="info">
            <AppenderRef ref="Console" level="all"/>
            <AppenderRef ref="AccessFile" level="info"/>
            <AppenderRef ref="ErrorFile" level="warn"/>
        </Root>
        <Logger name="org.springframework.boot.web.embedded" level="warn"/>
        <Logger name="org.springframework" level="warn"/>
        <Logger name="com.zaxxer.hikari" level="warn"/>
        <Logger name="org.flywaydb.core" level="warn"/>
        <Logger name="com.mybatis" level="warn"/>
        <logger name="com.kingtom.kirin" level="info"/>
        <logger name="com.kingtom.shengtai" level="info"/>
    </Loggers>
</configuration>