我在Spring启动应用程序中有一个奇怪的logback问题。
我有一个简单的配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true" scanPeriod="30 seconds">
<!--include resource="org/springframework/boot/logging/logback/base.xml"/-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<logger name="com.mypackage" level="debug"/>
<root level="debug">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
我开始使用-Dlogging.configurationFile=..
正确的路径
应用程序选取文件并提供以下输出:
16:34:58,174 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeFilter scanning period to 30 seconds
16:34:58,212 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[/home/..../logback.xml]] every 30 seconds.
16:34:58,212 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
16:34:58,238 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
16:34:58,250 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
16:34:58,384 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
16:34:58,615 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.myPackage] to DEBUG
16:34:58,615 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
16:34:58,615 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
16:34:58,618 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
16:34:58,622 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@447ecd43 - Registering current configuration as safe fallback point
pom.xml
如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
jcl 除 slf4j 和 slf4 之外
另外,我已从春季背景中排除了commons-logging
。
我在这里做错了什么?
答案 0 :(得分:0)
我获得了外部logback.xml文件以使用logging.config = file:但不能使用-Dlogback.configurationFile =
答案 1 :(得分:0)
请确保外部logback.xml文件在类路径中 。它应该被拿起来。
还要确保您没有任何名为logback-test.xml的文件,否则它将获得优先权,并将被使用。