在项目中使用 log4j 和 log4j2 时找不到配置文件?
No configuration file found when using log4j with log4j2 in project?
在我们的项目中,我们使用 log4j 和 log4j2。当我 运行 Junits 时,我收到错误消息:No log4j2 configuration file found.
但是 log4j.properties 文件在该位置已经可用。使用 Google
我发现它需要 logj2.xml 文件然后我提供了 log4j2.xml 文件。 Junits 运行s 顺利。
log4j2 是否支持 属性 文件?
Log4j2 确实支持 属性 文件。
属性 文件可以通过以下两种方式之一提供给log4j2:
- 在
"log4j.configurationFile"
系统属性中设置配置文件路径(扩展名为.properties
)。
- 将配置文件命名为
log4j2.properties
(或 log4j2-test.properties
)并将其保存在类路径中。
您可以了解更多关于 log4j2 配置的信息here。
在我们的项目中,我们使用 log4j 和 log4j2。当我 运行 Junits 时,我收到错误消息:No log4j2 configuration file found.
但是 log4j.properties 文件在该位置已经可用。使用 Google
我发现它需要 logj2.xml 文件然后我提供了 log4j2.xml 文件。 Junits 运行s 顺利。
log4j2 是否支持 属性 文件?
Log4j2 确实支持 属性 文件。
属性 文件可以通过以下两种方式之一提供给log4j2:
- 在
"log4j.configurationFile"
系统属性中设置配置文件路径(扩展名为.properties
)。 - 将配置文件命名为
log4j2.properties
(或log4j2-test.properties
)并将其保存在类路径中。
您可以了解更多关于 log4j2 配置的信息here。