本文介绍了获取异常org.apache.logging.slf4j.SLF4JLoggerContext无法强制转换为org.apache.logging.log4j.core.LoggerContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用apache-log4j-2.0.2我的代码非常简单:
My code is very simple using apache-log4j-2.0.2:
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
public class Log4jtest {
static Logger log =Logger.getLogger(Log4jtest.class);
public static void main(String[] args) {
BasicConfigurator.configure();
log.debug("This is debug message");
}
}
但我得到的例外就像:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext``
at org.apache.log4j.Logger.getLogger(Logger.java:41)
at Log4jtest.<clinit>(Log4jtest.java:11)
为什么异常来自简单程序?
Why is the exception coming from a simple program?
推荐答案
log4j-to-slf4j-2.0.2.jar
log4j-to-slf4j-2.0.2-sources.jar
log4j-slf4j-impl-2.0.2.jar
log4j-slf4j-impl-2.0.2-sources.jar
这篇关于获取异常org.apache.logging.slf4j.SLF4JLoggerContext无法强制转换为org.apache.logging.log4j.core.LoggerContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!