Class path contains multiple SLF4J bindings.问题原因及解决方案

  1. 问题背景
    在进行logback的日志输出测试时,显示如下错误
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/LenovoSoftstore/softdate/Idealp/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/LenovoSoftstore/softdate/Idealp/.m2/repository/ch/qos/logback/logback-classic/1.2.6/logback-classic-1.2.6.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.slf4j.impl.Log4jLoggerFactory]
log4j:WARN No appenders could be found for logger (com.health.controller.UserController).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

2、原因
根据上面的错误提示,存在多个SLF4J bindings绑定,即存在多个slf4j的实现类,按上图所示这两个实现分别是logback-classic-1.2.6和slf4j-log4j12-1.6.1,我们需要的是logback而不是log4j,
3、解决方案
因此,我们去掉log4j的依赖就行;查找slf4j-log4j12-1.6.1并将其删除

你可能感兴趣的:(SpringMVC,log4j,apache,java)