<?xml version="1.0" encoding="UTF-8"?>
< configuration debug = " false" > < springProfile name = " local" > < property name = " LOG_HOME" value = " ../logs" /> < property name = " COLOR_PATTERN" value = " %black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" /> < appender name = " STDOUT" class = " ch.qos.logback.core.ConsoleAppender" > < encoderclass = " ch.qos.logback.classic.encoder.PatternLayoutEncoder" > < pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} ----- [%thread] %-5level %logger{50}:%L - %msg%n</ pattern> </ encoder> </ appender> < root level = " debug" > < appender-ref ref = " STDOUT" /> </ root> < logger name = " com.app" level = " debug" additivity = " false" > < appender-ref ref = " STDOUT" /> </ logger> </ springProfile> < springProfile name = " !local" > < property name = " LOG_HOME" value = " ../logs" /> < property name = " COLOR_PATTERN" value = " %black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" /> < appender name = " FILE" class = " ch.qos.logback.core.rolling.RollingFileAppender" > < File> ${LOG_HOME}/gateway.out.log</ File> < rollingPolicy class = " ch.qos.logback.core.rolling.TimeBasedRollingPolicy" > < fileNamePattern> ${LOG_HOME}/gateway-%d{yyyy-MM-dd}.log.%i</ fileNamePattern> < timeBasedFileNamingAndTriggeringPolicy class = " ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP" > < maxFileSize> 50MB</ maxFileSize> </ timeBasedFileNamingAndTriggeringPolicy> < maxHistory> 90</ maxHistory> </ rollingPolicy> < append> true</ append> < encoder class = " ch.qos.logback.classic.encoder.PatternLayoutEncoder" > < pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</ pattern> </ encoder> </ appender> < appender name = " ERROR-FILE" class = " ch.qos.logback.core.rolling.RollingFileAppender" > < File> ${LOG_HOME}/err.log</ File> < rollingPolicy class = " ch.qos.logback.core.rolling.TimeBasedRollingPolicy" > < fileNamePattern> ${LOG_HOME}/gateway.err.log.%d{yyyy-MM-dd}.log.%i</ fileNamePattern> < timeBasedFileNamingAndTriggeringPolicy class = " ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP" > < maxFileSize> 10MB</ maxFileSize> </ timeBasedFileNamingAndTriggeringPolicy> < maxHistory> 90</ maxHistory> </ rollingPolicy> < append> true</ append> < encoder> < Pattern> [mts][%d{yyyy-MM-dd HH:mm:ss.sss}][%-5level] %msg %n</ Pattern> < charset> UTF-8</ charset> </ encoder> < filter class = " ch.qos.logback.classic.filter.LevelFilter" > < level> error</ level> < onMatch> ACCEPT</ onMatch> < onMismatch> DENY</ onMismatch> </ filter> </ appender> < appender name = " STDOUT" class = " ch.qos.logback.core.ConsoleAppender" > < encoderclass = " ch.qos.logback.classic.encoder.PatternLayoutEncoder" > < pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} --- [%thread] %-5level %logger{50}:%L - %msg%n</ pattern> </ encoder> </ appender> < logger name = " com.apache.ibatis" level = " warn" > < appender-ref ref = " FILE" /> </ logger> < logger name = " java.sql.Connection" level = " warn" > < appender-ref ref = " FILE" /> </ logger> < logger name = " java.sql.Statement" level = " warn" > < appender-ref ref = " FILE" /> </ logger> < logger name = " java.sql.PreparedStatement" level = " warn" > < appender-ref ref = " FILE" /> </ logger> < root level = " WARN" > < appender-ref ref = " FILE" /> < appender-ref ref = " ERROR-FILE" /> </ root> </ springProfile> </ configuration>
<logger name="java.sql.PreparedStatement" level="warn"><appender-ref ref="FILE"/></logger>配置具体的包输出的日志级别,不配置则按照全局默认 <root level="WARN"> application.properties中也可配置
logging:level:com:app:gateway:server:GatewayApplication: info #全局配置warn级别,这样写就可以看到启动成功的标记,要不看不到java.sql.PreparedStatement: infoio.netty: WARN
logger.level 的生效级别低于application.properties中的