<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="carrera" monitorInterval="60" shutdownHook="disable" >
    <Appenders>
        <Console name="stdout" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
        </Console>
        <RollingFile name="CarreraAppender" fileName="logs/carrera.log"
                     filePattern="logs/old/carrera-%d{yyyy-MM-dd-HH}.%i.log.gz">
            <PatternLayout pattern="%d{DEFAULT} [ %p ] %c{1} - %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy>
                <Delete basePath="logs" maxDepth="2">
                    <IfAny>
                        <IfAccumulatedFileSize exceeds="${env:LOG_SAVE_SIZE}"/>
                        <IfLastModified age="${env:LOG_SAVE_TIME}"/>
                    </IfAny>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <RollingFile name="WarnAppender" fileName="logs/error.log"
                     filePattern="logs/old/error-%d{yyyy-MM-dd}.%i.log">
            <PatternLayout pattern="%d{DEFAULT} [ %p ] %c{1} - %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy>
                <Delete basePath="logs" maxDepth="2">
                    <IfLastModified age="1d"/>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <RollingFile name="SwitchAppender" fileName="logs/switch.log"
                     filePattern="logs/old/switch-%d{yyyy-MM-dd-HH}.%i.log">
            <PatternLayout pattern="%d{DEFAULT} [ %p ] %c{1} - %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy>
                <Delete basePath="logs" maxDepth="2">
                    <IfLastModified age="30d"/>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <RollingFile name="MetricAppender" fileName="logs/metric.log"
                     filePattern="logs/old/metric-%d{yyyy-MM-dd-HH}.%i.log">
            <PatternLayout pattern="%d{DEFAULT} [ %p ] %c{1} - %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy>
                <Delete basePath="logs" maxDepth="2">
                    <IfLastModified age="1d"/>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <RollingFile name="BackupRestoreAppender" fileName="logs/backupRestore.log"
                     filePattern="logs/old/backupRestore-%d{yyyy-MM-dd-HH}.%i.log">
            <PatternLayout pattern="%d{DEFAULT} [ %p ] %c{1} - %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy>
                <Delete basePath="logs" maxDepth="2">
                    <IfLastModified age="30d"/>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="warn">
            <AppenderRef ref="WarnAppender" level="WARN"/>
        </Root>

        <AsyncLogger name="com.xiaojukeji.chronos" level="${env:LOG_CARRERA_LEVEL}" additivity="false">
            <AppenderRef ref="CarreraAppender"/>
            <AppenderRef ref="WarnAppender" level="error"/>
        </AsyncLogger>
        <AsyncLogger name="SwitchLogger" level="INFO" additivity="false">
            <AppenderRef ref="SwitchAppender"/>
        </AsyncLogger>
        <AsyncLogger name="MetricLogger" level="INFO" additivity="false">
            <AppenderRef ref="MetricAppender"/>
        </AsyncLogger>
        <AsyncLogger name="BackupRestoreLogger" level="INFO" additivity="false">
            <AppenderRef ref="BackupRestoreAppender"/>
        </AsyncLogger>
        <AsyncLogger name="com.xiaojukeji.carrera" level="INFO" additivity="false">
            <AppenderRef ref="CarreraAppender"/>
            <AppenderRef ref="WarnAppender" level="WARN"/>
        </AsyncLogger>
    </Loggers>
</Configuration>
