SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder"; [英] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

查看:47
本文介绍了SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My application is to be deployed on both tcServer and WebSphere 6.1. This application uses ehCache and so requires slf4j as a dependency. As a result I've added the slf4j-api.jar (1.6) jar to my war file bundle.

应用程序在 tcServer 中运行良好,但出现以下错误:

The application works fine in tcServer except for the following error:

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.

However, when I deploy in WebSphere I get a java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder.

还伴随着Failed to load class "org.slf4j.impl.StaticMDCBinder"

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

I've checked the classpaths of both application servers and there is no other slf4j jar.

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

Does anyone have any ideas what may be happening here?

推荐答案

我在使用 WebSphere 6.1 时遇到了同样的问题.正如 Ceki 指出的那样,WebSphere 使用了大量 jar,其中一个指向旧版本的 slf4j.

I had the same issue with WebSphere 6.1. As Ceki pointed out, there were tons of jars that WebSphere was using and one of them was pointing to an older version of slf4j.

No-Op 回退仅在 slf4j -1.6+ 时发生,因此任何比这更旧的情况都会引发异常并停止您的部署.

The No-Op fallback happens only with slf4j -1.6+ so anything older than that will throw an exception and halts your deployment.

SLf4J 站点 中有一个文档可以解决这个问题.我遵循了这一点,并将 slf4j-simple-1.6.1.jar 与我已经拥有的 slf4j-api-1.6.1.jar 一起添加到我的应用程序中.

There is a documentation in SLf4J site which resolves this. I followed that and added slf4j-simple-1.6.1.jar to my application along with slf4j-api-1.6.1.jar which I already had.

如果您使用 Maven,请添加以下依赖项,${slf4j.version}最新版slf4j

If you use Maven, add the following dependencies, with ${slf4j.version} being the latest version of slf4j

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>${slf4j.version}</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>${slf4j.version}</version>
</dependency>

这解决了我的问题.希望它可以帮助其他遇到此问题的人.

This solved my issue. Hope it helps others who have this issue.

这篇关于SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆