Logback configuration, error log and general separation

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <springProperty scope="context" name="common.logDir" source="common.logDir"/>
    <!-- 彩色日志 -->
    <!-- 彩色日志依赖的渲染类 -->
    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
    <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
    <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
    <!-- 彩色日志格式 -->
    <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>

    <appender name="CONSOLE-LOG" class="ch.qos.logback.core.ConsoleAppender">
        <layout class = "ch.qos.logback.classic.PatternLayout" > 
            < pattern > $ {CONSOLE_LOG_PATTERN} </ pattern > 
        </ layout > 
    </ the appender > 
    <-! Get info higher than the level (including the info level), but other error level log -> 
    < the appender name = "the INFO-the lOG" class = "ch.qos.logback.core.rolling.RollingFileAppender" > 
        < filter class = "ch.qos.logback.classic.filter.LevelFilter" > 
            < Level > ERROR </level>
            <onMatch>DENY</onMatch>
            <onMismatch>ACCEPT</onMismatch>
        </filter>
        <encoder>
            <pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n</pattern>
        </encoder>
        <!--滚动策略-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--路径-->
            <fileNamePattern>${common.logDir}/log/jby_job.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
    </appender>
    <appender name="ERROR-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <encoder>
            <pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n</pattern>
        </encoder>
        <!--滚动策略-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--路径-->
            <fileNamePattern>${common.logDir}/log/jby_job_error.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
    </appender>
    < The root Level = "info" > 
        < the appender-REF REF = "the CONSOLE-the LOG" /> 
        < the appender-REF REF = "the INFO-the LOG" /> 
        < the appender-REF REF = "ERROR-the LOG" /> 
    </ the root > 

    <! - asynchronous output -> 
    < the appender name = "ASYNC-the INFO" class = "ch.qos.logback.classic.AsyncAppender" > 
        <! - without losing the default log, if 80% of the cohort. Man, is discarded TRACT, DEBUG, INFO level log -> 
        < discardingThreshold >0</discardingThreshold> 
        <! - change the default queue depth, this value will affect the performance of the default value is 256. -> 
        < QueueSize > 256 </ QueueSize > 
        <! - add additional appender, only add up to a -> 
        < appender-ref ref = "INFO-lOG" /> 
    </ appender > 
    < appender name = "ASYNC-ERROR" class = "ch.qos.logback.classic.AsyncAppender" > 
        <-! is not lost log default. If 80% of the full queue, TRACT, DEBUG, INFO level log is discarded -> 
        < discardingThreshold > 0 </ discardingThreshold >
        <! -Change the default depth of the queue, this value can affect the performance of the default value is 256 -> 
        < QueueSize > 256 </ QueueSize > 
        <-! Add additional the appender, only add up to a -> 
        < the appender REF- REF = "the LOG-ERROR" /> 
    </ the appender > 
</ Configuration >

 

Guess you like

Origin www.cnblogs.com/ljb161108/p/11333987.html