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

<configuration>
    <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>
                %d{HH:mm:ss.SSS} [%thread] %-5level %c %M %L - %msg%n
            </pattern>
        </layout>
    </appender>

    <!-- info 日志文件 -->
    <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>DENY</onMatch>
            <onMismatch>ACCEPT</onMismatch>
        </filter>
        <encoder>
            <pattern>
                %d{HH:mm:ss.SSS} %-5level %c %M %L - %msg%n
            </pattern>
            <charset>UTF-8</charset>
        </encoder>
        <!-- 滚动策略 -->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>
                logs/content-info.%d.log
            </fileNamePattern>
        </rollingPolicy>
    </appender>

    <!-- error 日志文件 -->
    <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <encoder>
            <pattern>
                %d{HH:mm:ss.SSS} %-5level %c %M %L - %msg%n
            </pattern>
            <charset>UTF-8</charset>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>
                logs/content-error.%d.log
            </fileNamePattern>
        </rollingPolicy>
    </appender>

    <springProfile name="dev">
        <root level="info">
            <appender-ref ref="consoleLog"></appender-ref>
        </root>
    </springProfile>
    <springProfile name="test">
        <root level="info">
            <appender-ref ref="fileInfoLog"></appender-ref>
            <appender-ref ref="fileErrorLog"></appender-ref>
        </root>
    </springProfile>
    <springProfile name="prod">
        <root level="info">
            <appender-ref ref="fileInfoLog"></appender-ref>
            <appender-ref ref="fileErrorLog"></appender-ref>
        </root>
    </springProfile>
    <springProfile name="cluster">
        <root level="info">
            <appender-ref ref="fileInfoLog"></appender-ref>
            <appender-ref ref="fileErrorLog"></appender-ref>
        </root>
    </springProfile>
</configuration>