– Start
接着上个例子,我们提供一个 logback.xml
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
得到如下输出。
07:30:26,506 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
07:30:26,507 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
07:30:26,507 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/0_Shangbo/Dev/Workspace/logback/target/classes/logback.xml]
07:30:27,101 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
07:30:27,102 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
07:30:27,129 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
07:30:27,163 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
07:30:27,472 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
07:30:27,473 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
07:30:27,475 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
07:30:27,477 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@198e2867 - Registering current configuration as safe fallback point
07:30:27.521 [main] DEBUG demo05.App - debug
07:30:27.529 [main] INFO demo05.App - info
07:30:27.531 [main] WARN demo05.App - warn
07:30:27.531 [main] ERROR demo05.App - error
从上面的输出可以看到,logback使用了 logback.xml
– 更多参见:SLF4J+Logback 精萃
– 声 明:转载请注明出处
– Last Updated on 2019-08-24
– Written by ShangBo on 2019-08-24
– End