为了在多个项目之间共享 logback 配置,我们将 logback.xml 文件嵌入到一个公共 jar 中。例如mylogger.jar。项目依赖于这个 jar 进行日志记录,因此它总是在类路径上。这意味着 logback.xml 将按照记录在https://logback.qos.ch/manual/configuration.html#auto_configuration但是,如果另一个 jar,例如otherlib.jar,也嵌入了 logback.xml 文件,我们将看到警告09:27:03,122 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]09:27:03,122 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]09:27:03,122 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/WEB-INF/lib/mylogger.jar/logback.xml]09:27:03,123 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.09:27:03,123 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/WEB-INF/lib/mylogger.jar/logback.xml]09:27:03,123 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/WEB-INF/lib/otherlib.jar/logback.xml]更糟糕的是,有时它不会选择正确的 logback.xml,因为根据Controlling the classpath in a servlet,这种行为是不确定的。是否有任何机制可以强制警告使构建失败?这将提醒我们注意上述情况,而可以忽略警告。
添加回答
举报
0/150
提交
取消