问题描述:
启动tomcat,发现tomcat无法启动,catalina.out有如下错误日志:
INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext
SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.Log4jLoggerFactory
at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:274)
at org.springframework.web.context.ContextCleanupListener.<clinit>(ContextCleanupListener.java:43)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:145)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4860)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5495)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:224)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
问题分析:
检查lib库下面,发现今天更新过log4j和logback组合,总共有如下包:
slf4j-api-1.7.5.jar
slf4j-log4j12-1.6.1.jar
log4j-1.2.16.jar
log4j-over-slf4j-1.7.5.jar
logback-core-1.1.2.jar
logback-classic-1.1.2.jar
通过查询资料发现,包slf4j-log4j12-1.6.1.jar 和log4j有冲突。
解决方法:
删除后正常,删除这个:slf4j-log4j12-1.6.1.jar
附件常见组合:
log4j+slf4j
slf4j-api-1.7.5.jar
slf4j-log4j12-1.6.1.jar
log4j-1.2.16.jar
slf4j+logback
logback-core-1.1.2.jar
logback-classic-1.1.2.jar
slf4j-api-1.7.5.jar
参考资料:
http://logback.qos.ch/documentation.html
http://logging.apache.org/log4j/1.2/
http://www.slf4j.org/
本文出自 “痞子厨子戏子” 博客,转载请与作者联系!
tomcat 日志log4j,slf4j,logback冲突
原文地址:http://chenwei.blog.51cto.com/32183/1825820