本文介绍了SLF4J:java.lang.IllegalStateException:无法成功初始化org.slf4j.LoggerFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的pom文件中有以下maven依赖关系:

I have the following maven dependency in my pom file:

<!-- depends on slf4j-api, log4j -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.6.4</version>
</dependency>

当我将项目部署到tomcat时,我收到错误消息:

When I deploy the project into tomcat, I am getting the error message:

SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.ExceptionInInitializerError
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4819)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5466)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:288)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at org.springframework.web.context.ContextCleanupListener.<clinit>(ContextCleanupListener.java:43)
    ... 16 more

当我查看部署的war文件在战争档案中我看到以下罐子(其中包括):

When I look at the deployed war file, I see in the war file the following jars (among others):

slf4j-api-1.6.4.jar
slf4j-log4j12-1.6.4.jar

奇怪的是,我不看到任何 log4j.jar (即使它是 slf4j-log4j12-1.6.4.jar的依赖

The strange thing is, that I don't see there any log4j.jar (even though it's a dependency of slf4j-log4j12-1.6.4.jar

问题:


  1. 为什么是 log4j.jar 不包含在战争文件中?

  1. Why was log4j.jar not packed in the war file?

错误信息是什么意思,以及如何解决方案

What does the error message mean and how to solve it?


推荐答案

文件在存储库中。删除Maven存储库中的整个 log4j 目录修复它,一旦我做了Maven>更新依赖关系,并重新下载它们。

I had this issue due to a bad jar file in the repository. Deleting the entire log4j directory in the Maven repository fixed it once I did Maven > Update Dependencies and it re-downloaded them.

这篇关于SLF4J:java.lang.IllegalStateException:无法成功初始化org.slf4j.LoggerFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 00:14