logback异步输出日志

logback异步输出日志

代码块


<configuration debug="true" scan="true" scanPeriod="30 seconds">
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss} [%level] - %m%npattern>
        encoder>
    appender>

    <appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/var/log/sssj_.%d{yyyy-MM-dd}.logFileNamePattern>
            <MaxHistory>180MaxHistory>
        rollingPolicy>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %thread %X{invokeNo} %logger{40} %msg%npattern>
            <charset>UTF-8charset>
        encoder>
        
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERRORlevel>
            <onMatch>ACCEPTonMatch>
            <onMismatch>DENYonMismatch>
        filter>
    appender>
    
    <appender name="async_log" class="ch.qos.logback.classic.AsyncAppender">
        <discardingThreshold>0discardingThreshold>
        <queueSize>10queueSize>
        <appender-ref ref="errorAppender"/>
    appender>

    
    <root level="info">
        <appender-ref ref="async_log"/>
        <appender-ref ref="rolling"/>
        <appender-ref ref="errorAppender"/>
    root>
configuration>

你可能感兴趣的:(logback)