本文介绍了如何在项目中包含多个log4j2.xml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My Project is composed of multiple modules. Each module can run on its own and have a separate log4j2.xml

Say Project X由三个模块组成:

Say Project X is composed of three modules:


  1. 模块A有log4j2.xml(包含记录器和附加程序)

  2. 模块B有log4j2.xml

  3. 模块C有log4j2.xml

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

While integrating the modules, I have to manually copy-paste the Loggers and Appenders from each module's log4j2.xml into the project specific log4j2.xml file.

为了避免复制粘贴,我找了 XInclude 包含多个文件,但仅当Appenders和Logger位于不同文件中时才支持。

To avoid copy-paste, I've looked for XInclude to include multiple files but it supports only when Appenders and Loggers are in different file.http://logging.apache.org/log4j/2.x/manual/configuration.html#XInclude

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

How to do XInclude of multiple log4j2.xml files?

非常感谢任何帮助。

推荐答案

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

In the Log4j2 v2.6 release, composite configuration feature is added. With this feature, multiple log4j2 configuration files are allowed.

参考

-

-

这篇关于如何在项目中包含多个log4j2.xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 04:32