<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <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="R"/>
    </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,oracle">
        <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>