<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <!--<include resource="org/springframework/boot/logging/logback/base.xml"/>-->
    <!-- 定义log文件的目录 -->
    <property name="LOG_HOME" value="d:\log"></property>


    <conversionRule conversionWord="sampleClass"  converterClass="com.lz.common.layouts.SampleClassConverter" />
    <conversionRule conversionWord="sampleLine"  converterClass="com.lz.common.layouts.SampleLineConverter" />


    
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <!-- %.-1level 只显示信息级别的首字母,%-5level 左对齐显示信息级别全称 -->
           <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} 【%p】 [%sampleClass:%sampleLine] %m%n</Pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/info.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/logs/info.%d{yyyy-MM-dd-HH }.%i.log</fileNamePattern>
            <!--单文件日志最大的大小-->
            <maxFileSize>500MB</maxFileSize>

            <!-- <maxHistory>180</maxHistory>-->
            <!--总文件日志最大的大小-->
            <!--<totalSizeCap>100GB</totalSizeCap>-->
        </rollingPolicy>
        <encoder>
           <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} 【%p】 [%sampleClass:%sampleLine] %m%n</Pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/warn.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/logs/warn.%d{yyyy-MM-dd-HH }.%i.log</fileNamePattern>
            <maxFileSize>500MB</maxFileSize>
            <!-- <maxHistory>180</maxHistory>-->
            <!--<totalSizeCap>100GB</totalSizeCap>-->
        </rollingPolicy>
        <encoder>
           <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} 【%p】 [%sampleClass:%sampleLine] %m%n</Pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
    </appender>
    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/logs/error.%d{yyyy-MM-dd-HH }.%i.log</fileNamePattern>
            <maxFileSize>500MB</maxFileSize>
            <!-- <maxHistory>180</maxHistory>-->
            <!--<totalSizeCap>100GB</totalSizeCap>-->
        </rollingPolicy>
        <encoder>
           <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} 【%p】 [%sampleClass:%sampleLine] %m%n</Pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
    </appender>
    <appender name="ALL_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/all.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>${LOG_HOME}/logs/all.%i.log.gz</fileNamePattern>
            <minIndex>0</minIndex>
            <maxIndex>0</maxIndex>
        </rollingPolicy>
        <triggeringPolicy
                class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>1GB</maxFileSize>
        </triggeringPolicy>
        <encoder>
           <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} 【%p】 [%sampleClass:%sampleLine] %m%n</Pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>

    <appender name="PL_BI_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/bi.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/logs/bi.%d{yyyy-MM-dd-HH }.%i.log</fileNamePattern>
            <!--单文件日志最大的大小-->
            <maxFileSize>500MB</maxFileSize>

            <!-- <maxHistory>180</maxHistory>-->
            <!--总文件日志最大的大小-->
            <!--<totalSizeCap>100GB</totalSizeCap>-->
        </rollingPolicy>
        <encoder>
           <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} 【%p】 [%sampleClass:%sampleLine] %m%n</Pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>

    <logger name="PL_BI" level="INFO">
        <appender-ref ref="PL_BI_FILE"/>
    </logger>

    <root level="INFO">
        <!--<appender-ref ref="INFO_FILE" />-->
        <!--<appender-ref ref="WARN_FILE" />-->
        <!--<appender-ref ref="ERROR_FILE" />-->
        <!--<appender-ref ref="ALL_FILE" />-->
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>
