<?_xml version=”1.0” encoding=”UTF-8”?>





    _

    1. <property name="logback-ext.appName" value="${logback-ext.appName}"/><br /> <property name="LOG_PATH" value="${logback-ext.base-path}/${logback-ext.appName}"/>
    2. <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender"><br /> <encoder><br /> _<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--><br /> _<pattern>${logback-ext.pattern}</pattern><br /> _<!--window 控制台使用GBK编码 linux中使用utf-8--><br /> _<charset>UTF-8</charset><br /> _<!-- 此处设置字符集 --><br /> _</encoder><br /> </appender>
    3. <appender name="dailyRollingFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"><br /> <File>${LOG_PATH}/info.log</File><br /> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br /> _<!-- daily rollover --><br /> _<FileNamePattern>${LOG_PATH}/info-%d{yyyyMMdd}.log.%i</FileNamePattern><br /> <timeBasedFileNamingAndTriggeringPolicy<br /> class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br /> <maxFileSize>256MB</maxFileSize><br /> </timeBasedFileNamingAndTriggeringPolicy><br /> _<!-- keep 30 days' worth of history --><br /> _<maxHistory>30</maxHistory><br /> </rollingPolicy>
    4. <layout class="ch.qos.logback.classic.PatternLayout"><br /> <Pattern>${logback-ext.pattern}</Pattern><br /> </layout>
    5. <encoder><br /> <Pattern>${logback-ext.pattern}</Pattern><br /> <charset>UTF-8</charset><br /> _<!-- 此处设置字符集 --><br /> _</encoder><br /> </appender>
    6. <appender name="errorRollingAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"><br /> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"><br /> <level>ERROR</level><br /> </filter><br /> <File>${LOG_PATH}/error.log</File><br /> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br /> <fileNamePattern>${LOG_PATH}/error-%d{yyyyMMdd}.log.%i</fileNamePattern><br /> <timeBasedFileNamingAndTriggeringPolicy<br /> class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br /> <maxFileSize>256MB</maxFileSize><br /> </timeBasedFileNamingAndTriggeringPolicy><br /> <maxHistory>30</maxHistory><br /> </rollingPolicy><br /> <layout class="ch.qos.logback.classic.PatternLayout"><br /> <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}-%msg%n</Pattern><br /> </layout><br /> </appender>
    7. <root level="INFO"><br /> <appender-ref ref="dailyRollingFileAppender"/><br /> <appender-ref ref="errorRollingAppender"/><br /> <appender-ref ref="consoleAppender"/><br /> </root><br /></configuration>

    _# 日志规范统一格式 定义
    _logback-ext.pattern=%magenta(%d{yyyy-MM-dd HH:mm:ss}) %(${PID:- }) %highlight(%-5level) %yellow(%thread) %green(%logger) %msg%n