<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="log.dir" value="."/>

    <appender name="USER_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <Encoding>UTF-8</Encoding>
        <file>${log.dir}/${log.file.name}</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>${log.dir}/${log.file.name}.%i.gz</FileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>20</maxIndex>
        </rollingPolicy>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>1GB</maxFileSize>
        </triggeringPolicy>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="BAD_RECORD_FILE"
              class="ch.qos.logback.core.FileAppender">
        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
            <evaluator>
                <expression>logger.endsWith("StdoutPluginCollector") || null != throwable</expression>
            </evaluator>
            <OnMatch>ACCEPT</OnMatch>
            <OnMismatch>DENY</OnMismatch>
        </filter>
        <Encoding>UTF-8</Encoding>
        <file>${log.dir}/${log.file.name}.dirty-record</file>
        <layout class="cch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - %msg%n
            </pattern>
        </layout>
    </appender>

    <root level="${loglevel:-INFO}">
        <appender-ref ref="USER_LOG_FILE"/>
        <appender-ref ref="BAD_RECORD_FILE" />
    </root>
</configuration>