Getting Exception org.apache.logging.slf4j.SLF4JLoggerContext 不能 cast to org.apache.logging.log4j.core.LoggerContext
我的代码非常简单,使用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)
为什么异常来自一个简单的程序?