logback.xml通用配置模板



<configuration scanPeriod="60 seconds" debug="false">
    <property name="LOG_HOME" value="${user.dir}/logs/patchtool/" />

    
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} %level [%thread] [%logger{100}.%method:%line] - %msg%npattern>
            <charset>UTF-8charset>
        layout>
    appender>

    
    <appender name="FILE-debug"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>DEBUGlevel>
        filter>
        <File>${LOG_HOME}/@bic.patchtool.debug.logFile>
        
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>${LOG_HOME}/@bic.patchtool.debug.%i.logFileNamePattern>
            <MinIndex>1MinIndex>
            <MaxIndex>10MaxIndex>
        rollingPolicy>
        <triggeringPolicy
            class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>25MBMaxFileSize>
        triggeringPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} %level [%thread] [%logger{50}.%method:%line] %msg%nPattern>
            <charset>UTF-8charset>
        layout>
    appender>

    <appender name="FILE-error"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERRORlevel>
        filter>
        <File>${LOG_HOME}/@bic.patchtool.error.logFile>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>${LOG_HOME}/@bic.patchtool.error.%i.logFileNamePattern>
            <MinIndex>1MinIndex>
            <MaxIndex>10MaxIndex>
        rollingPolicy>
        <triggeringPolicy
            class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>25MBMaxFileSize>
        triggeringPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} %level [%thread] [%logger{50}.%method:%line] %msg%nPattern>
            <charset>UTF-8charset>
        layout>
    appender>

    <appender name="FILE-info"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFOlevel>
        filter>
        <File>${LOG_HOME}/@bic.patchtool.info.logFile>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>${LOG_HOME}/@bic.patchtool.info.%i.logFileNamePattern>
            <MinIndex>1MinIndex>
            <MaxIndex>10MaxIndex>
        rollingPolicy>
        <triggeringPolicy
            class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>25MBMaxFileSize>
        triggeringPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} %level [%thread] [%logger{50}.%method:%line] %msg%nPattern>
            <charset>UTF-8charset>
        layout>
    appender>

    <appender name="FILE-trace"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>TRACElevel>
        filter>
        <File>${LOG_HOME}/@bic.patchtool.trace.logFile>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>${LOG_HOME}/@bic.patchtool.trace.%i.logFileNamePattern>
            <MinIndex>1MinIndex>
            <MaxIndex>10MaxIndex>
        rollingPolicy>
        <triggeringPolicy
            class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>25MBMaxFileSize>
        triggeringPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} %level [%thread] [%logger{50}.%method:%line] %msg%nPattern>
            <charset>UTF-8charset>
        layout>
    appender>

    
    <logger name="com.datamanager" level="TRACE" additivity="false">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE-debug" />
        <appender-ref ref="FILE-info" />
        <appender-ref ref="FILE-error" />
        <appender-ref ref="FILE-trace" />
    logger>

    
    <root level="TRACE">
        <appender-ref ref="STDOUT" />
    root>

configuration>

你可能感兴趣的:(工具)