日志jar包冲突报错:Class path contains multiple SLF4J bindings

时间:2023-03-08 22:38:47

  问题现象:tomcat启动卡死,报错日志如下:

十一月 07, 2017 8:35:45 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ms-notify/WEB-INF/lib/log4j-slf4j-impl-2.9.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ms-notify/WEB-INF/lib/slf4j-log4j12-1.7.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

  问题定位:从日志里看到两个日志jar包冲突了:log4j-slf4j-impl-2.9.1.jar和slf4j-log4j12-1.7.2.jar

  解决问题:根据日志给出的本地tomcat路径,进入到lib下,删除其中一个,这里进入E:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ms-notify/WEB-INF/lib,删除log4j-slf4j-impl-2.9.1.jar,重启即可。