Logback日誌檔案配置模板
阿新 • • 發佈:2018-12-30
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true" scan="true" scanPeriod="30 secondes">
<property name="CONSOLE_APPENDER_NAME" value="CONSOLE"/>
<property name="FILE_APPENDER_NAME" value="FILE"/>
<property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSSS} - [Thread-%thread] -[level-%-5level] - [%class : %method : %line] - %msg %n" />
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSSS} - [Thread:%thread] - [level: %-5level] - [%class : %method : %line] - %msg %n"/>
<property name="FILE_NAME_PATTERN" value="%d{yyyy-MM-dd}.%i.log"/>
<property name="FILE_PATH" value="D:/Log/Test-Client-Log.log" />
<property name="ROOT_LEVEL" value="debug"/>
<appender name="${CONSOLE_APPENDER_NAME}" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern >
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="${FILE_APPENDER_NAME}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--<File></File>-->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${FILE_PATH}-${FILE_NAME_PATTERN}</FileNamePattern>
<MaxHistory>30</MaxHistory>
<maxFileSize>2MB</maxFileSize>
<totalSizeCap>10MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${FILE_LOG_PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="${ROOT_LEVEVL}">
<appender-ref ref="${CONSOLE_APPENDER_NAME}"/>
<appender-ref ref="${FILE_APPENDER_NAME}"/>
</root>
<logger name="com.apache.ibatis" level="TRACE"/>
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
</configuration>
標籤集中集中配置所有的自定義的變數,方便管理;具體的標籤的意思請參考- 解釋