<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="log.directory" value="logs/" />
    <property name="log.context.name" value="dd-job-console" />
    <property name="log.charset" value="UTF-8" />
    <property name="log.maxHistory" value="30" />
    <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] %msg %n" />
    <property name="log.error.log.level" value="WARN" />
    <property name="log.async.queue.size" value="1024" />
    
    <include resource="includedLogbackConfig.xml" optional="true" />
    <include resource="conf/includedLogbackConfig.xml" optional="true" />
    
    <contextName>${log.context.name}</contextName>
    
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder charset="${log.charset}">
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.directory}${log.context.name}-log.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${log.maxHistory}</maxHistory>
        </rollingPolicy>
        <encoder charset="${log.charset}">
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    
    <!-- Asynchronized log, for FILE only -->
    <appender name ="ASYNC_FILE" class= "ch.qos.logback.classic.AsyncAppender">
        <!-- Don't discard log, logback will discard TRACE, DEBUG, INFO log when queue 80% capacity reached by default. -->
        <discardingThreshold >0</discardingThreshold>
        <queueSize>${log.async.queue.size}</queueSize>
        <appender-ref ref = "FILE"/>
    </appender>
     
    <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
          <level>${log.error.log.level}</level>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.directory}${log.context.name}-error.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${log.maxHistory}</maxHistory>
        </rollingPolicy>
        <encoder charset="${log.charset}">
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    
    <root>
        <level value="INFO" />
        <appender-ref ref="STDOUT" />
        <appender-ref ref="ASYNC_FILE" />
        <appender-ref ref="ERROR" />
    </root>
</configuration>
