- 问题背景
在进行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并将其删除文章来源地址https://www.toymoban.com/news/detail-672706.html
文章来源:https://www.toymoban.com/news/detail-672706.html
到了这里,关于Class path contains multiple SLF4J bindings.问题原因及解决方案的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!