这个 Log4j 的报错,会导致系统的 log4j.xml 配置(失效)被覆盖重置。
2018-04-27 17:31:43.248 org.slf4j.helpers.Util report
System.err: SLF4J: Class path contains multiple SLF4J bindings.
2018-04-27 17:31:43.250 org.slf4j.helpers.Util report
System.err: SLF4J: Found binding in [jar:file:/Users/jack/aipqa/swork.info/swork.info.server/target/swork-info/WEB-INF/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
2018-04-27 17:31:43.250 org.slf4j.helpers.Util report
System.err: SLF4J: Found binding in [jar:file:/Users/jack/aipqa/swork.info/swork.info.server/target/swork-info/WEB-INF/lib/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
2018-04-27 17:31:43.251 org.slf4j.helpers.Util report
System.err: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
2018-04-27 17:31:43.640 org.slf4j.helpers.Util report
System.err: SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
含义为:
发生jar包冲突了:
分别为:
[jar:file:/Users/jack/aipqa/swork.info/swork.info.server/target/swork-info/WEB-INF/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[jar:file:/Users/jack/aipqa/swork.info/swork.info.server/target/swork-info/WEB-INF/lib/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
解决方案:
移除其中一个jar包即可。
<dependency>
<groupId>xxx</groupId>
<artifactId>yyy</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>