logback.xml

it2022-05-05  144

logback的启动顺序

14:45:31,360 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 14:45:31,361 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 14:45:31,361 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/maintain/target/classes/logback.xml]

 logback配置信息

<?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/defaults.xml"/> <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/> <include resource="org/springframework/boot/logging/logback/console-appender.xml"/> <property name="SSCM_LOG_PATTERN" value="${SSCM_LOG_PATTERN:-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39}[%L] : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <pattern>${SSCM_LOG_PATTERN}</pattern> </encoder> <file>${LOG_FILE}</file> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${LOG_FILE}.%i</fileNamePattern> <minIndex>1</minIndex> <maxIndex>30</maxIndex> </rollingPolicy> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>50MB</MaxFileSize> </triggeringPolicy> </appender> <root level="INFO"> <appender-ref ref="CONSOLE"/> <appender-ref ref="FILE"/> </root> </configuration>

 打印日志结果:

2019-07-18 11:40:13.345 DEBUG [maintain,1c7a32cd740c2e00,1c7a32cd740c2e00,true] 18461 --- [http-nio-18071-exec-5] c.l.c.pscm.facility.proxy.MaterialProxy [72] : [MaterialProxy#queryLegalPlantByCodesAndEnabledIsTrue] x-xss-protection: 1; mode=block 2019-07-18 11:40:13.345 DEBUG [maintain,1c7a32cd740c2e00,1c7a32cd740c2e00,true] 18461 --- [http-nio-18071-exec-5] c.l.c.pscm.facility.proxy.MaterialProxy [72] : [MaterialProxy#queryLegalPlantByCodesAndEnabledIsTrue]

打印格式解析:

<!-- 格式化输出:%d表示日期,LOG_LEVEL_PATTERN:-%5p表示日志级别,${PID:-}父进程,%thread表示线程名,[%-40.40logger{39}:%line]位置信息,类名+行数, %msg:日志消息,%n是换行符--> %d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} [%X{traceId}] ${PID:- } [%thread] [%-40.40logger{39}:%line] %m%n

 


最新回复(0)