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

<configuration scan="false" scanPeriod="60 seconds" debug="false">

    <property name="LOG_HOME" value="/data/project/logs/wxservice/"/>
    <!-- 定义日志的根目录 -->
    <property name="TRACE_DIR" value="trace" />
    <property name="DEBUG_DIR" value="debug" />
    <property name="INFO_DIR" value="info" />
    <property name="WARN_DIR" value="warn" />
    <property name="ERROR_DIR" value="error" />
    <!-- 定义日志文件名称 -->
    <property name="TRACE_FILE_NAME" value="wxservice-trace"></property>
    <property name="DEBUG_FILE_NAME" value="wxservice-debug"></property>
    <property name="INFO_FILE_NAME" value="wxservice-info"></property>
    <property name="WARN_FILE_NAME" value="wxservice-warn"></property>
    <property name="ERROR_FILE_NAME" value="wxservice-error"></property>

    <!-- 定义日志级别颜色 -->
    <!-- 控制台显示 -->
    <property name="STD_CONSOLE_LOG_PATTERN"
              value="%d{yyyy-MM-dd HH:mm:ss.SSS}[%yellow(%thread)]-[%highlight(%-5level)][%green(%logger{70}):%cyan(%line)] - %msg%n"/>

    <!-- 日志文件打印 -->
    <property name="CONSOLE_LOG_PATTERN"
              value="%d{yyyy-MM-dd HH:mm:ss.SSS}[%thread]-[%-5level][%logger{70}:%line] - %msg%n"/>

    <!-- ConsoleAppender 控制台输出 appender -->
    <appender name="stdoutAppender" class="ch.qos.logback.core.ConsoleAppender">
        <!--
        日志输出格式：%d表示日期时间，%thread表示线程名，%-5level：级别从左显示5个字符宽度
        %logger{70} 表示logger名字最长50个字符，否则按照句点分割。 %msg：日志消息，%n是换行符
        -->
        <encoder>
            <pattern>${STD_CONSOLE_LOG_PATTERN}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>


    <!-- TRACE 日志 appender  -->
    <appender name="traceAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- 指定日志文件的名称 -->
        <file>${LOG_HOME}/${TRACE_DIR}/${TRACE_FILE_NAME}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/${TRACE_DIR}/${TRACE_FILE_NAME}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
            <MaxHistory>365</MaxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>TRACE</level>
            <!--<onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>-->
        </filter>
    </appender>


    <!-- DEBUG 日志 appender  -->
    <appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- 指定日志文件的名称 -->
        <file>${LOG_HOME}/${DEBUG_DIR}/${DEBUG_FILE_NAME}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/${DEBUG_DIR}/${DEBUG_FILE_NAME}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
            <MaxHistory>365</MaxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <!--<onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>-->
        </filter>
    </appender>


    <!-- phrase 日志 appender  -->
    <appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- 指定日志文件的名称 -->
        <file>${LOG_HOME}/${INFO_DIR}/${INFO_FILE_NAME}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/${INFO_DIR}/${INFO_FILE_NAME}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
            <MaxHistory>365</MaxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <!--<onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>-->
        </filter>
    </appender>


    <!-- WARN 日志 appender  -->
    <appender name="warnAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- 指定日志文件的名称 -->
        <file>${LOG_HOME}/${WARN_DIR}/${WARN_FILE_NAME}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/${WARN_DIR}/${WARN_FILE_NAME}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
            <MaxHistory>365</MaxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARN</level>
            <!--<onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>-->
        </filter>
    </appender>


    <!-- ERROR 日志 appender  -->
    <appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- 指定日志文件的名称 -->
        <file>${LOG_HOME}/${ERROR_DIR}/${ERROR_FILE_NAME}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/${ERROR_DIR}/${ERROR_FILE_NAME}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
            <MaxHistory>365</MaxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter"><!-- 只打印错误日志 -->
            <level>ERROR</level>
        </filter>
    </appender>

    <logger name="org.apache.shiro" level="DEBUG" additivity="false" />
    <logger name="com.zaxxer.hikari" level="ERROR" additivity="false" />
    <logger name="org.apache" level="ERROR" />
    <logger name="org.springframework.context.annotation.ClassPathBeanDefinitionScanner" level="INFO" />
    <logger name="org.springframework.beans.factory.support.DefaultListableBeanFactory" level="INFO" />
    <logger name="org.springframework.data.convert.CustomConversions" level="INFO"/>
    <logger name="org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener" level="INFO" />
    <logger name="org.springframework.boot.autoconfigure.web.servlet.WelcomePageHandlerMapping" level="INFO" />
    <logger name="org.springframework" level="DEBUG" />
    <logger name="io.netty" level="INFO" />
    <logger name="org.mybatis" level="INFO" />
    <logger name="org.hibernate" level="INFO" />
    <logger name="io.lettuce" level="INFO" />
    <logger name="springfox.documentation" level="INFO" />

    <logger name="com.netflix.discovery" level="ERROR" />
    <logger name="com.netflix.eureka" level="ERROR" />
    <logger name="org.springframework.security" level="ERROR" />

    <root level="DEBUG" >
        <appender-ref ref="stdoutAppender" />
        <!--<appender-ref ref="traceAppender" />-->
        <appender-ref ref="debugAppender" />
        <!--<appender-ref ref="infoAppender" />-->
        <!--<appender-ref ref="warnAppender" />-->
        <!--<appender-ref ref="errorAppender" />-->
    </root>
</configuration>