logback启动日志不能关闭
0
使用logback设置了debug=false
,但是依旧在控制台有一段logback本身的日志信息输出:
15:03:22,532 |-INFO in ch.qos.logback.classic.LoggerContext[Snail] - Could NOT find resource [logback-test.xml]
15:03:22,533 |-INFO in ch.qos.logback.classic.LoggerContext[Snail] - Could NOT find resource [logback.groovy]
15:03:22,534 |-INFO in ch.qos.logback.classic.LoggerContext[Snail] - Found resource [logback.xml] at [file:/E:/GITEE/snail/target/classes/logback.xml]
15:03:22,610 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
15:03:22,612 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [Snail]
15:03:22,612 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
15:03:22,615 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [file]
15:03:22,660 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@258931371 - No compression will be used
15:03:22,661 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@258931371 - Will use the pattern logs/Snail.log-%d{yyyy-MM-dd} for the active file
15:03:22,664 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern 'logs/Snail.log-%d{yyyy-MM-dd}'.
15:03:22,664 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
15:03:22,671 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Sun Mar 10 15:03:11 CST 2019
15:03:22,680 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[file] - This appender no longer admits a layout as a sub-component, set an encoder instead.
15:03:22,680 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[file] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
15:03:22,680 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[file] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
15:03:22,680 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
15:03:22,683 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[file] - Active log file name: logs/Snail.log
15:03:22,683 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[file] - File property is set to [logs/Snail.log]
15:03:22,684 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
15:03:22,685 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [console]
15:03:22,686 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
15:03:22,687 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
15:03:22,687 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [file] to Logger[ROOT]
15:03:22,687 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [console] to Logger[ROOT]
15:03:22,687 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:03:22,688 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@3c19aaa5 - Registering current configuration as safe fallback point
其实仔细看一下warn
这个信息就能知道具体的原因了,因为logback配置默认推荐使用encoder
来替换原来的layout
标签,所以替换一下就可以了:
<!--
推荐:使用encoder替换layout,否者系统会在启动时有一个警告日志。
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>${system.pattern}</pattern>
</layout>
-->
<encoder>
<charset>${system.charset}</charset>
<pattern>${system.pattern}</pattern>
</encoder>