<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="log4j2ConfigureXML">
    <Appenders>
        <!--
        定义标准输出的日志格式(SYSTEM_OUT)
        %d: 表示日期
        %level:表示日志级别，%-5level,表示5个占位符
        %t: 方法名
        %m: 消息体(即我们填的信息)
        %C: 包名 (%F: 类文件名,这里没加)
        %L: 行号
        ThresholdFilter过滤器,这里指定接受的日志级别,低于该级别的日志直接丢弃
        -->
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5level [%t] (%C:%L): %m%n"/>
            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
        </Console>
        <!--指定(api)日志文件-->
        <RollingFile name="LogFileAppApi"
                     fileName="logs/ccui_api.log"
                     filePattern="logs/ccui_api-%d{yyyy-MM-dd}--%i.log">
            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="%d %-5level [%t] (%C:%L): %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="100 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="20">
                <Delete basePath="logs" maxDepth="2">
                    <IfFileName glob="*.log" />
                    <!--30天,不得少于2天-->
                    <IfLastModified age="30d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <!--指定(sql)日志文件-->
        <RollingFile name="LogFileAppSql"
                     fileName="logs/ccui_sql.log"
                     filePattern="logs/ccui_sql-%d{yyyy-MM-dd}--%i.log">
            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="%d %-5level [%t] (%C:%L): %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="100 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="20">
                <Delete basePath="logs" maxDepth="2">
                    <IfFileName glob="*.log" />
                    <!--30天,不得少于2天-->
                    <IfLastModified age="30d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <!-- 滚动更新,TimeBasedTriggeringPolicy 每天创建一个日志文件 -->
        <RollingFile name="LogFileApp" fileName="logs/ccui_all.log"
                     filePattern="logs/ccui_all-%d{yyyy-MM-dd}--%i.log">
            <PatternLayout>
                <Pattern>%d %-5level [%t] (%C:%L): %m%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="100 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="20">
                <Delete basePath="logs" maxDepth="2">
                    <IfFileName glob="*.log" />
                    <!--30天,不得少于2天-->
                    <IfLastModified age="30d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
    </Appenders>
    <Loggers>
        <!-- 可以根据自己需求设置输出级别，这里示例设置的全是debug级别 -->
        <logger name="LogFileAppApi">
            <AppenderRef ref="LogFileAppApi" level="debug"/>
            <AppenderRef ref="LogFileApp" level="debug"/>
            <AppenderRef ref="Console" level="debug"/>
        </logger>
        <logger name="LogFileAppSql">
            <AppenderRef ref="LogFileAppSql" level="debug"/>
            <AppenderRef ref="LogFileApp" level="debug"/>
            <AppenderRef ref="Console" level="debug"/>
        </logger>
        <logger name="cn.com.capcloud">
            <AppenderRef ref="LogFileApp" level="debug"/>
            <AppenderRef ref="Console" level="debug"/>
        </logger>
        <!-- 全局输出级别：共8个级别，按照从低到高为 all < trace < debug < info < warn < error < fatal < off -->
        <!-- 建议：开发环境 debug，生产环境 error 或者 info -->
        <root level="debug">
        </root>
    </Loggers>
</Configuration>