SLF4J报错问解决

报错内容如下:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

原来这是因为sl4j和log4j的不兼容导致的,具体处理方案如下:

首先看看你工程中的sl4j-api的版本(比如我的是1.7.21),然后在http://mvnrepository.com/搜索slf4j-log4j12,会出现SLF4J LOG4J 12 Binding,点击进入,会有很多版本的slf4j-log4j12,我们点击1.7.21版本的slf4j-log4j12进入详细信息页面,查看依赖的log4j,这个版本的slf4j-log4j12依赖的是1.2.71版本的log4j。

一般非maven项目主要添加三个包,如:log4j-1.2.17.jar,slf4j-api-1.7.5.jar,slf4j-log4j12-1.7.5.jar

下载地址:https://repo1.maven.org/maven2/org/slf4j/

原文地址:https://www.cnblogs.com/JAYIT/p/13992953.html