Resource [logback.xml] occurs multiple times on the classpath.
15:16:57,390 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 15:16:57,390 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 15:16:57,390 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/F:/e/workspace/z-use/target/classes/logback.xml] 15:16:57,391 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath. 15:16:57,391 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/F:/e/workspace/z-base/target/classes/logback.xml] 15:16:57,391 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/F:/e/workspace/z-use/target/classes/logback.xml] 15:16:57,476 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set 15:16:57,493 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 15:16:57,501 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 15:16:57,507 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 15:16:57,570 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG 15:16:57,570 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT] 15:16:57,571 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 15:16:57,574 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@1996cd68 - Registering current configuration as safe fallback point z-use 15:16:57.579 [main] DEBUG BBB - 2222
通过这个日志可以看出
If no such file is found, it checks for the file logback.xml in the classpath..
官方文档中所说的in the classpath 是会检测到所有的 logback.xml 但最终只选择了当前配置作为安全的可靠的点(除了当前的这个配置,其他的配置具有不可控性,比如有多个jar中均有logback.xml 这是该选哪个就成了问题)
这种将logback.xml 文件包含在 jar包中的做法是不可取的,如果为了方便自己的模块测试,可以包含一个logback-test.xml 这个配置文件不会包含在jar包中
通过启动参数指定classpath 将配置文件放入classpath配置的文件夹