logback日志模板

logback.xml

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

    <jmxConfigurator/>

    <property name="pattern" value="%d{HH:mm:ss.SSS} [%t] %-5p %c{36}:%L - %msg%n" />

    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${pattern}</pattern>
        </encoder>
    </appender>

    <appender name="RollingFileInfo" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>./logs/info.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>./logs/info.log-%d{yyyy-MM-dd}.%i.zip</fileNamePattern>
            <maxHistory>60</maxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>debug</level>
        </filter>
        <encoder>
            <pattern>${pattern}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <appender name="RollingFileWarn" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>./logs/warn.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>./logs/warn.log-%d{yyyy-MM-dd}.%i.zip</fileNamePattern>
            <maxHistory>60</maxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>warn</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <encoder>
            <pattern>${pattern}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <appender name="RollingFileError" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>./logs/error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>./logs/error.log-%d{yyyy-MM-dd}.%i.zip</fileNamePattern>
            <maxHistory>60</maxHistory>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>error</level>
        </filter>
        <encoder>
            <pattern>${pattern}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <logger name="org.apache.tomcat.util.scan.StandardJarScanner" level="ERROR" />
    <logger name="com.surfilter.ga.face.dao" level="INFO" />

    <logger name="com.surfilter.ga" level="DEBUG" />

    <root level="WARN">
        <!--<appender-ref ref="console"/>-->
        <appender-ref ref="RollingFileInfo" />
        <appender-ref ref="RollingFileWarn" />
        <appender-ref ref="RollingFileError" />
    </root>

</configuration>

 

posted @ 2019-04-19 15:32  codercg  阅读(433)  评论(0编辑  收藏  举报