JJ1*_*180 547 java websphere slf4j
我的应用程序将部署在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.
Run Code Online (Sandbox Code Playgroud)
但是,当我在WebSphere中部署时,我得到了一个java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder.
我检查了两个应用程序服务器的类路径,没有其他的slf4j jar.
有没有人有任何想法可能会发生在这里?
pra*_*ann 476
我在WebSphere 6.1中遇到了同样的问题.正如Ceki指出的那样,WebSphere正在使用大量的罐子,其中一个指向旧版本的slf4j.
No-Op回滚只发生在slf4j -1.6+上,因此任何比这更旧的东西都会抛出异常并停止部署.
SLf4J网站上有一个解决此问题的文档.我跟着它,并添加slf4j-simple-1.6.1.jar到我的应用程序slf4j-api-1.6.1.jar,我已经有.
这解决了我的问题.希望它可以帮助那些有这个问题的人.
Igo*_*kov 335
这是为那些从谷歌搜索来到这里的人.
如果您使用maven,只需添加以下内容即可
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
要么
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
ash*_*ish 41
您需要在类路径中添加以下jar文件:slf4j-simple-1.6.2.jar.如果您没有,请下载.请参阅http://www.slf4j.org/codes.html#multiple_bindings
Ben*_*uer 38
只需将其添加到您的pom.xml:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
Wol*_*ahl 29
这里有一些答案建议将slf4j-simple依赖项添加到你的maven pom文件中.您可能想要检查最新版本.
在https://mvnrepository.com/artifact/org.slf4j/slf4j-simple, 您将找到最新版本的SLF4J Simple Binding.选择最适合你的那个(从2017年到2017年的1.7.25仍然是2018-02的稳定版本)并将其包含在你的pom.xml中.
Beta版2018年3月
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.0-alpha0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
稳定的版本
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.8.0-beta4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
小智 25
我面临同样的错误.我在本地开发中配置了slf4j-api,slf4j-log4j12和log4j.所有配置都很好,但我从mvnrepository复制的slf4j-log4j12依赖项有测试范围<scope>test</scope>.当我删除它时,每件事都很好.
有时愚蠢的错误打破了我们的脑袋;)
Edw*_*ard 20
有时我们应该看到警告中的注释,例如.SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details..
您可以搜索此警告来的原因.
添加从罐子中的一个*slf4j-nop.jar,slf4j-simple.jar,slf4j-log4j12.jar,slf4j-jdk14.jar或logback-classic.jar*到类路径中应该解决的问题.
compile "org.slf4j:slf4j-api:1.6.1"
compile "org.slf4j:slf4j-simple:1.6.1"
例如,将上面的代码添加到您build.gradle或pom.xmlmaven项目的相应代码中.
sto*_*333 15
将文件slf4j-log4j12-1.6.4.jar放在类路径中就可以了.
sho*_*han 10
如果您正在使用maven进行依赖关系管理,那么您只需在pom.xml中添加以下依赖项即可
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
对于非Maven用户只需下载库并将其放入项目类路径中.
在这里您可以看到详细信息:http://www.mkyong.com/wicket/java-lang-classnotfoundexception-org-slf4j-impl-staticloggerbinder/
SLF4j是各种日志框架的抽象.因此,除了拥有slf4j之外,您还需要在类路径中包含任何日志框架,如log4j或logback(etc).
有一个想法指的第一个孩子步骤在http://logback.qos.ch/manual/introduction.html
小智 7
当我收到以下错误时,我遇到了这个问题:
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.
Run Code Online (Sandbox Code Playgroud)
当我slf4j-api-1.7.5.jar在我的libs.
尽管我尝试了整个建议的补充 jars,例如slf4j-log4j12-1.7.5.jar,slf4j-simple-1.7.5错误消息仍然存在。当我添加slf4j-jdk14-1.7.5.jar到java库时,问题终于解决了。
在http://www.slf4j.org/download.html获取整个 slf4j 包
在 Websphere 的情况下,您有旧版本的 slf4j-api.jar 1.4.x。或 1.5.x 位于某处。您在 tcServer 上观察到的行为(即故障转移到 NOP)发生在 slf4j 版本 1.6.0 及更高版本上。确保您在所有平台上使用 slf4j-api-1.6.x.jar,并且类路径上没有放置旧版本的 slf4j-api。
小智 5
Slf4j是底层日志框架的外观,如log4j,logback,java.util.logging.
为了连接底层框架,slf4j使用绑定.
如果错过了绑定jar,则抛出上述错误.您可以下载此jar并将其添加到classpath.
对于maven依赖,
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
除了slf4j-log4j12-1.7.21.jar之外,这个依赖项还会将slf4j-api-1.7.21.jar以及log4j-1.2.17.jar引入到你的项目中
参考:http://www.slf4j.org/manual.html
请将以下依赖项添加到 pom 以解决此问题。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我在使用带有Java 9库的Spring-boot-2应用程序时遇到了类似的问题。
在我的pom.xml中添加以下依赖项为我解决了这个问题:
<dependency>
<groupId>com.googlecode.slf4j-maven-plugin-log</groupId>
<artifactId>slf4j-maven-plugin-log</artifactId>
<version>1.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
作为 jar 包含和纯 maven 解决方案的替代方案,您可以将它从 maven 中包含在 gradle 中。
1.7.25// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
api group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
Run Code Online (Sandbox Code Playgroud)
将其放在build.gradle文件的依赖项中。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
将上述依赖项放在 pom.xml 文件中
| 归档时间: |
|
| 查看次数: |
779688 次 |
| 最近记录: |