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

    <!--加载spring的日志配置文件 -->
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>

    <property name="LOG_PATH" value="/data/logs"/>
    <!--设置系统日志目录-->
    <property name="APP_DIR" value="dxhy-passengerTicket"/>
    <!-- 记录日志天数 -->
    <property name="MAX_HISTORY" value="30"/>
    <!-- 每个日志文件大小 -->
    <property name="MAX_FILE_SIZE" value="1GB"/>
    <!-- 日志文件总大小 -->
    <property name="TOTAL_SIZE" value="30GB"/>
    <!-- 日志格式 -->
    <!--    <property name="PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%line]- %msg%n "/>-->
    <property name="PATTERN"
              value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%thread]) %clr(%-40.40logger{39}){cyan} %clr(:){faint} %clr([%line]) %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
   <!-- 项目名称 -->
    <contextName>${APP_DIR}</contextName>

    <!-- 引用logback 日志配置 -->
    <include resource="dxhy-logback.xml"/>

    <logger name="com.dxhy" level="debug"/>
    <logger name="springfox.documentation.spring.web" level="error"/>

    <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>

    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} [%line] - %msg%n</pattern>
        </encoder>
    </appender>

    <!--    <appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
    <!--        <File>${LOG_FILE}.log</File>-->
    <!--        <encoder>-->
    <!--            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} [%line] - %msg%n</pattern>-->
    <!--        </encoder>-->
    <!--        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
    <!--            <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log-->
    <!--            </fileNamePattern>-->
    <!--            <maxHistory>15</maxHistory>-->
    <!--        </rollingPolicy>-->
    <!--    </appender>-->

    <root level="info">
        <appender-ref ref="stdout"/>
        <appender-ref ref="error"/>
        <appender-ref ref="process"/>
        <!--        <appender-ref ref="R"/>-->
        <!-- 增加skywalking日志输出 -->
<!--        <appender-ref ref="skywalking-stdout"/>-->
<!--        <appender-ref ref="skywalking-rollingAppender"/>-->
<!--        <appender-ref ref="skywalking-gpclog"/>-->
        <!-- 增加skywalking日志输出 end-->
    </root>

    <logger name="noModule" level="INFO"/>
    <logger name="org.codehaus" level="INFO"/>
    <logger name="org.apache" level="INFO"/>
    <logger name="org.springframework" level="INFO"/>
    <logger name="net.sf.ehcache" level="INFO"/>
    <logger name="druid.sql" level="INFO"/>

    <!-- 开发、测试环境 -->
    <springProfile name="dev,test,std,pre">
        <logger name="org.springframework.web" level="INFO"/>
        <logger name="org.springboot.sample" level="INFO"/>
        <logger name="com.dxhy" level="DEBUG"/>
    </springProfile>

    <!-- 生产环境 -->
    <springProfile name="pro">
        <logger name="org.springframework.web" level="ERROR"/>
        <logger name="org.springboot.sample" level="ERROR"/>
        <logger name="com.dxhy" level="ERROR"/>
    </springProfile>

</configuration>