我的应用程序将部署在tcServer和WebSphere 6.1上。这个应用程序使用ehCache,因此需要slf4j作为依赖项。 因此,我将slf4j-api.jar (1.6) jar添加到war文件包中。

应用程序在tcServer中正常工作,除了以下错误:

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.

然而,当我在WebSphere中部署时,我得到了一个java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder。

同时伴有加载类“org.slf4j.impl.StaticMDCBinder”失败

我已经检查了两个应用服务器的类路径,没有其他slf4j jar。

有人知道这里会发生什么吗?


当前回答

这是我的5美分…

我在进行测试时也遇到了同样的问题。因此,我通过仅为测试运行时添加一个实现来解决这个问题。我在这个项目中使用gradle。

/ / https://mvnrepository.com/artifact/ch.qos.logback/logback-classic testRuntimeOnly组:'ch.qos。Logback ',名称:' Logback -classic', 版本:“1.2.3”

其他回答

我添加了这个依赖来解决这个问题:

https://mvnrepository.com/artifact/org.slf4j/slf4j-simple/1.7.25

我使用Jena,并将相关依赖项添加到pom.xml

<dependency> 
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.0.13</version>
</dependency>

我尝试添加SLF4J -simple,但它只是消失了“SLF4J:未能加载类”org.slf4j.impl。StaticLoggerBinder " "错误,但logback-classic显示更多详细信息。

官方文件

您需要在类路径中添加以下jar文件:slf4j-simple-1.6.2.jar。如果你没有,请下载。请参考http://www.slf4j.org/codes.html#multiple_bindings

我也遇到过类似的问题,通过以下方法解决了问题:

文件->项目结构… 模块->依赖项 从Maven ->搜索:slf4j.nop 单击最新版本-> Apply

对我来说,问题是: 在使用Hibernate时,我看到它已经使用了slf4j,而且它已经在我的类路径中,所以我决定使用它。 下一步-为slf4j添加imlementor,所以我添加到maven:

<dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>1.7.25</version>
</dependency>

但是它错误地失败了!SLF4J:加载类“org.slf4j.impl.StaticLoggerBinder”失败

解决方案是: Hibernate的slf4j依赖项是版本1.7.26,我添加了小版本依赖项1.7.25。当我修复了这个,一切都好了