<?xml version="1.0" encoding="UTF-8"?>
|
<configuration debug="false">
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
<property name="FILE_LOG_PATTERN" value="${FILE_LOG_PATTERN:-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
|
<property name="LOG_HOME" value="./logs" />
|
|
<springProperty scope="context" name="port" source="server.port"/>
|
<springProperty scope="context" name="appName" source="spring.application.name"/>
|
|
<!-- 控制台输出 -->
|
<appender name="CONSOLE_LOG" class="ch.qos.logback.core.ConsoleAppender">
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
</encoder>
|
</appender>
|
|
<!-- 按照每天生成日志文件 -->
|
<appender name="DEBUG_LOG"
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<!-- 日志文件输出的文件名 -->
|
<FileNamePattern>${LOG_HOME}/${port}/%d{yyyy-MM-dd}/${appName}-debug.log</FileNamePattern>
|
<!-- 日志文件保留天数 -->
|
<MaxHistory>10</MaxHistory>
|
</rollingPolicy>
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
<pattern>${FILE_LOG_PATTERN}</pattern>
|
</encoder>
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<level>DEBUG</level>
|
<onMatch>ACCEPT</onMatch>
|
<onMismatch>DENY</onMismatch>
|
</filter>
|
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
<MaxFileSize>10MB</MaxFileSize>
|
</triggeringPolicy>
|
</appender>
|
|
<appender name="ERROR_LOG"
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<FileNamePattern>${LOG_HOME}/${port}/%d{yyyy-MM-dd}/${appName}-error.log</FileNamePattern>
|
</rollingPolicy>
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
<pattern>${FILE_LOG_PATTERN}</pattern>
|
</encoder>
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<level>ERROR</level>
|
<onMatch>ACCEPT</onMatch>
|
<onMismatch>DENY</onMismatch>
|
</filter>
|
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
<MaxFileSize>10MB</MaxFileSize>
|
</triggeringPolicy>
|
</appender>
|
|
<logger name="com.changhong.epc" />
|
<logger name="com.apache.ibatis" />
|
<logger name="org.apache.http" level="ERROR" />
|
<logger name="java.sql" />
|
<logger name="org.springframework" level="INFO" />
|
<logger name="com.ibatis" />
|
<logger name="com.ibatis.common.jdbc.SimpleDataSource" />
|
<logger name="com.ibatis.common.jdbc.ScriptRunner" />
|
<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" />
|
<logger name="java.sql.Connection" />
|
<logger name="java.sql.Statement" />
|
<logger name="java.sql.PreparedStatement" />
|
|
<springProfile name="test">
|
<root level="DEBUG">
|
<appender-ref ref="CONSOLE_LOG" />
|
<appender-ref ref="DEBUG_LOG" />
|
<appender-ref ref="ERROR_LOG" />
|
</root>
|
</springProfile>
|
|
<springProfile name="formal">
|
<root level="ERROR">
|
<appender-ref ref="CONSOLE_LOG" />
|
<appender-ref ref="DEBUG_LOG" />
|
<appender-ref ref="ERROR_LOG" />
|
</root>
|
</springProfile>
|
</configuration>
|