<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <!--参考 https://blog.csdn.net/Inke88/article/details/75007649-->
    <!--
    springboot 对应配置
        logging.level.root=info
        logging.path=/logs/guansc-api
    -->
    <!-- 固定配置 START -->
    <!--<property name="context.name" value="guansc-api" />-->
    <!--<property name="log.path" value="../logs/guansc-api" />-->
    <springProperty scope="context" name="context.name" source="spring.application.name"/>
    <springProperty scope="context" name="log.path" source="logging.path"/>

    <property name="log.pattern" value='%d{yyyy-MM-dd_HH:mm:ss.SSS};%level;%C{0};%M;%L;%msg%n'/>
    <property name="roll.file.suffix" value="%d{yyyy-MM-dd}.tar.gz"/>
    <contextName>${context.name}</contextName>
    <appender name="ACCESS"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/access.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/access.${roll.file.suffix}
            </fileNamePattern>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    <appender name="BIZ"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/biz.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/biz.${roll.file.suffix}
            </fileNamePattern>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    <appender name="EXCEPTION"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/exception.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/exception.${roll.file.suffix}
            </fileNamePattern>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    <!--请求访问控制-->
    <logger name="access" level="INFO">
        <appender-ref ref="ACCESS"/>
    </logger>
    <!--业务日志-->
    <logger name="biz" level="TRACE">
        <appender-ref ref="BIZ"/>
    </logger>
    <!--异常日志-->
    <logger name="exception" level="ERROR">
        <appender-ref ref="EXCEPTION"/>
    </logger>
    <!-- 固定配置 END -->
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoder 默认配置为PatternLayoutEncoder -->
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    <root level="debug">
        <appender-ref ref="CONSOLE"/>
    </root>
</configuration>
