Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflow

Posted qingxin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflow相关的知识,希望对你有一定的参考价值。

Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError

 

SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. 
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:66)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
....
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
at org.apache.log4j.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:51)
... 11 more

 

原因是引用了两个关于log4j的jar,造成死循环

log4j-over-slf4j-1.7.7.jar

slf4j-log4j12-1.7.7.jar

但只引用slf4j-log4j12-1.7.7.jar会提示org.apache.log4j.Level这个class找不到

要使用log4j记录日志,其实只用引用log4j-over-slf4j-1.7.7.jar就可以了

解决办法:删除slf4j-log4j12包,包括myeclipse工作空间下

 

以上是关于Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflow的主要内容,如果未能解决你的问题,请参考以下文章

Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path 解决过程

Java学习-051-Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempt

SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path异常分析

Buffer overrun detected

开浏览器 出现buffer overrun detected 求助!!!

Frameworks detected: Android framework is detected in the project