SLF4j多个log4j2的实现类导致日志生成不了

Posted sxhong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SLF4j多个log4j2的实现类导致日志生成不了相关的知识,希望对你有一定的参考价值。

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/link/data/server/test_tomcat_main/webapps/ROOT/WEB-INF/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/link/data/server/test_tomcat_main/webapps/ROOT/WEB-INF/lib/slf4j-log4j12-1.7.10.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]


如上加载正确了,有时候会变成这样:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/link/data/server/test_tomcat_main/webapps/ROOT/WEB-INF/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/link/data/server/test_tomcat_main/webapps/ROOT/WEB-INF/lib/log4j-slf4j-impl-2.10.0.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]

原因是有多个实现类,删除掉slf4j-log4j12-1.7.10.jar jar包即可


以上是关于SLF4j多个log4j2的实现类导致日志生成不了的主要内容,如果未能解决你的问题,请参考以下文章

log4j2+slf4j日志不打印问题

使用Slf4j集成Log4j2构建项目日志系统的完美解决方案

使用Slf4j集成Log4j2构建项目日志系统的完美解决方案

使用Slf4j集成Log4j2构建项目日志系统的完美解决方案

SpringBoot使用日志

log4j2 or slf4j ? java日志框架,今天得说清楚!