ClassCastException Log4jLoggerFactory LoggerContex

44 篇文章 0 订阅
5 篇文章 0 订阅

http://my.oschina.net/u/249914/blog/192987

  xception sending context initialized event to listener instance of class ch.qos.logback.ext.spring.web.LogbackConfigListener java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
今天调试web项目,使用Spring+各种组件。 
其中用到了slf4j-core,slf4j-simple,slf4j-api,logback-classic,slf4j-log4j12。。。 
运行后报一下  错误   


SEVERE: Exception sending context initialized event to listener instance of class ch.qos.logback.ext.spring.web.LogbackConfigListener 
java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext 
at ch.qos.logback.ext.spring.LogbackConfigurer.initLogging(LogbackConfigurer.java:72) 
at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging(WebLogbackConfigurer.java:142) 
at ch.qos.logback.ext.spring.web.LogbackConfigListener.contextInitialized(LogbackConfigListener.java:54) 
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
at java.lang.Thread.run(Thread.java:744) 


java.lang.NullPointerException 
at ch.qos.logback.ext.spring.LogbackConfigurer.shutdownLogging(LogbackConfigurer.java:104) 
at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.shutdownLogging(WebLogbackConfigurer.java:187) 
at ch.qos.logback.ext.spring.web.LogbackConfigListener.contextDestroyed(LogbackConfigListener.java:49) 
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831) 
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478) 
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$StartChild.call(ContainerBase.java:1559) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 

at java.lang.Thread.run(Thread.java:744)


解决方案: 
把slf4j-simple,slf4j-log4j12引用去掉,因为他们都实现了org.slf4j.impl.StaticLoggerBinder。 
logback-classic也实现了org.slf4j.impl.StaticLoggerBinder,因为我要使用logback,所以留下了它。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值