<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>

    <springProfile name="dev">
        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            </encoder>
        </appender>
        <root level="INFO">
            <appender-ref ref="CONSOLE"/>
        </root>
        <logger name="org.hibernate.SQL" level="DEBUG"/>
        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>
        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>
        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>
        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>
        <!--swagger 类型转换异常日志去除-->
        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>
        <logger name="org.freemarker" level="DEBUG"/>

        <!-- dingding log -->
        <appender name="HTTP_INVOKE_LOGGER_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
            <param name="append" value="true"/>
            <param name="encoding" value="UTF-8"/>
            <param name="threshold" value="INFO"/>
            <encoder>
                <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            </encoder>
        </appender>

        <!-- ding open sdk log -->
        <appender name="DING_OPEN_CLIENT_SDK_LOGGER_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
            <param name="append" value="true"/>
            <param name="encoding" value="UTF-8"/>
            <param name="threshold" value="INFO"/>
            <encoder>
                <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            </encoder>
        </appender>
        <logger name="HTTP_INVOKE_LOGGER" additivity="false">
            <level value="WARN"/>
            <appender-ref ref="HTTP_INVOKE_LOGGER_APPENDER"/>
        </logger>
        <logger name="DING_OPEN_CLIENT_SDK_LOGGER" additivity="false">
            <level value="WARN"/>
            <appender-ref ref="DING_OPEN_CLIENT_SDK_LOGGER_APPENDER"/>
        </logger>
        <!-- end of dingding log -->
    </springProfile>

    <springProfile name="test">
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <encoder>
                <pattern>${FILE_LOG_PATTERN}</pattern>
            </encoder>
            <file>/var/www/9th_test/app.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
                <fileNamePattern>app.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
                <maxFileSize>10MB</maxFileSize>
                <maxHistory>60</maxHistory>
            </rollingPolicy>
        </appender>
        <root level="INFO">
            <appender-ref ref="FILE"/>
        </root>
        <logger name="org.hibernate.SQL" level="DEBUG"/>
        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>
        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>
        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>
        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>
        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>
    </springProfile>

    <springProfile name="prod">
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <encoder>
                <pattern>${FILE_LOG_PATTERN}</pattern>
            </encoder>
            <file>/var/www/9th/app.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
                <fileNamePattern>app.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
                <maxFileSize>10MB</maxFileSize>
                <maxHistory>60</maxHistory>
            </rollingPolicy>
        </appender>
        <root level="INFO">
            <appender-ref ref="FILE"/>
        </root>
        <logger name="org.hibernate.SQL" level="DEBUG"/>
        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>
        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>
        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>
        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>
        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>
    </springProfile>

</configuration>
