gpt4 book ai didi

java - 如何在项目中包含多个 log4j2.xml 文件?

转载 作者:搜寻专家 更新时间:2023-11-01 03:00:56 27 4
gpt4 key购买 nike

我的项目由多个模块组成。每个模块都可以独立运行,有独立的log4j2.xml

假设项目 X 由三个模块组成:

  1. 模块 A 有 log4j2.xml(包含 Loggers 和 Appenders)
  2. 模块 B 有 log4j2.xml
  3. 模块C有log4j2.xml

在集成模块时,我必须手动将每个模块的 log4j2.xml 中的 LoggersAppenders 复制粘贴到项目特定的 log4j2.xml 文件中。

为了避免复制粘贴,我一直在寻找 XInclude 来包含多个文件,但它仅在 Appenders 和 Loggers 在不同的文件中时才支持。 http://logging.apache.org/log4j/2.x/manual/configuration.html#XInclude

如何对多个log4j2.xml文件进行XInclude?

非常感谢任何帮助。

最佳答案

在 Log4j2 v2.6 版本中,添加了复合配置功能。使用此功能,允许使用多个 log4j2 配置文件。

引用文献
- https://issues.apache.org/jira/browse/LOG4J2-494
- https://github.com/Kamal15/Log4j2Examples/blob/master/src/main/java/in/co/nmsworks/log4j2/examples/CompositeConfigurationExample.java

关于java - 如何在项目中包含多个 log4j2.xml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34671641/

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