<?xml version="1.0" encoding="UTF-8"?>
<!--monitorInterval：Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
<configuration status="WARN" monitorInterval="60">
    <Properties>
        <Property name="PID">????</Property>
        <Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
        <Property name="LOG_LEVEL_PATTERN">%5p</Property>
        <Property name="LOG_DATEFORMAT_PATTERN">yyyy-MM-dd HH:mm:ss.SSS</Property>
        <!-- 控制台日志格式化，包含颜色-->
        <Property name="CONSOLE_LOG_PATTERN">%clr{%d{${LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
        <!-- 日志文件默认输出格式,不带行号输出(行号显示会影响日志输出性能);%C:大写,类名;%M:方法名;%m:错误信息;%n:换行 -->
        <Property name="FILE_LOG_PATTERN">%d{${LOG_DATEFORMAT_PATTERN}} ${LOG_LEVEL_PATTERN} ${sys:PID} --- [%t] %-40.40c{1.} : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
        <!-- 日志默认同类型日志,同一文件夹下可以存放的数量,不设置此属性则默认为7个 -->
        <Property name="FILE_MAX_HISTORY">50</Property>
        <Property name="FILE_MAX_SIZE">50MB</Property>
        <Property name="PROJECT_PATH">/opt/projects/mall4j</Property>
    </Properties>

    <!--定义appender -->
    <Appenders>
        <!-- 默认的控制台日志输出，一般生产环境都是后台启动，这个没太大作用 -->
        <Console name="Console" target="SYSTEM_OUT" follow="false">
            <PatternLayout pattern="${sys:CONSOLE_LOG_PATTERN}" />
        </Console>

        <!--fileName 文件名称-->
        <!--filePattern 文件路径-->
        <RollingFile name="DefaultFile" fileName="${PROJECT_PATH}/log/api.log" filePattern="${PROJECT_PATH}/log/$${date:yyyy-MM}/api-%d{yyyy-MM-dd}-%i.log.gz">
            <PatternLayout>
                <Pattern>${sys:FILE_LOG_PATTERN}</Pattern>
            </PatternLayout>
            <DefaultRolloverStrategy max="${FILE_MAX_HISTORY}"/>
            <Policies>
                <!--TimeBasedTriggeringPolicy 与 filePattern 结合使用，目前表示每间隔1天保存一遍日志-->
                <TimeBasedTriggeringPolicy interval="1"/>
                <SizeBasedTriggeringPolicy size="${FILE_MAX_SIZE}" />
            </Policies>
        </RollingFile>
    </Appenders>

    <Loggers>
        <Logger name="org.mybatis" level="debug"/>
        <Logger name="com.yami.shop" level="debug"/>
        <Logger name="org.apache.catalina.startup.DigesterFactory" level="error" />
        <Logger name="org.apache.catalina.util.LifecycleBase" level="error" />
        <Logger name="org.apache.coyote.http11.Http11NioProtocol" level="warn" />
        <Logger name="org.apache.sshd.common.util.SecurityUtils" level="warn"/>
        <Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="warn" />
        <Logger name="org.eclipse.jetty.util.component.AbstractLifeCycle" level="error" />
        <Logger name="org.hibernate.validator.internal.util.Version" level="warn" />
        <Logger name="org.springframework.boot.actuate.endpoint.jmx" level="warn"/>
        <Logger name="org.mybatis" level="debug"/>
        <Logger name="com.yami.shop" level="debug"/>
        <!---->
        <Root level="info">
            <AppenderRef ref="DefaultFile" />
        </Root>
    </Loggers>
</configuration>