[英]NPE when using log4J-2.0-beta
I am checking out log4j2 via the overview documentation and I am getting the following exception when trying to setup the log4j2 logger: 我通过概述文档检查log4j2,并在尝试设置log4j2记录器时收到以下异常:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:129)
at HelloWorld.<clinit>(HelloWorld.java:5)
My test program is taken from the overview site: 我的测试程序来自概述站点:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class HelloWorld {
private static Logger logger = LogManager.getLogger("HelloWorld");
public static void main(String[] args) {
logger.info("Hello, World!");
}
}
I added all the provided jar files from the binary distribution to my build path. 我将所有提供的jar文件从二进制分发添加到我的构建路径。
What am I missing? 我错过了什么?
For anyone who stumble across this in the future: 对于任何在未来偶然遇到这种情况的人:
JAR log4j-core-2.0-beta2-sources
is the cause of the error. JAR log4j-core-2.0-beta2-sources
是导致错误的原因。 If you remove this JAR from your build path you can build properly. 如果从构建路径中删除此JAR,则可以正确构建。
I opened up a JIRA ticket on the ASF tracker located at https://issues.apache.org/jira/browse/LOG4J2-118 regarding this issue. 关于此问题,我在位于https://issues.apache.org/jira/browse/LOG4J2-118的ASF跟踪器上打开了一张JIRA票。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.