gpt4 book ai didi

java - 错误 StatusLogger 未找到 log4j2 配置文件。使用默认配置: logging only errors to the console

转载 作者:行者123 更新时间:2023-12-01 12:13:57 31 4
gpt4 key购买 nike

我正在尝试在 Ant build.xml 中使用 log4j2 来创建可执行的 .jar。该 jar 工作正常,但似乎 log4j2.xml 未被识别。我目前在 src 文件夹下有该文件。并在我的 build.xml 中设置类路径,如下所示。我的所有项目都会发生这种情况。放置 log4j2.xml 的正确目录是什么?除了将其添加到 build.xml 中的类路径之外还有什么要做吗?

    <path id = "classpath">  
<pathelement location="${junitJar}/junit-4.11.jar"/>
<pathelement location="${junitJar}/hamcrest-core-1.3.jar" />
<pathelement location="${classes.dir}"/>
<pathelement location="${log4jJar}/log4j-api-2.1.jar" />
<pathelement location="${log4jJar}/log4j-core-2.1.jar" />
<pathelement location="${src.dir}/log4j2.xml" />
</path>


compile:
jar:
run:
[java] ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
[java] Hello World!
main:
BUILD SUCCESSFUL
Total time: 1 second

最佳答案

将最后一个路径元素更改为:

   <pathelement location="${src.dir}/" />

可以工作,但实际上您可能应该在其他地方放置此文件。

在 ant 构建中,通常会将这些文件复制到类目录中,以便将其包含在 jar 文件中。

关于java - 错误 StatusLogger 未找到 log4j2 配置文件。使用默认配置: logging only errors to the console,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27116199/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com