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");
}
}
But I'm getting exception like:
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?