I would like to write a standard configuration file for log4j2 and extend it for special cases(test environments,modules, etc).Which would allow me to make a change in the main configuration file without repeating it in a alternative configuration file.
So far I have tried xinclude, which works great for separating the main elements of the xml configuration but I can not add anything to those elements after the include. I have tried using the xPointer but only the element scheme is supported and I am not sure if it is possible to include all the children of an element with the element scheme.
Example
Appenders file:
<Appenders>
<Appender 1 ...>
<Appender 2 ...>
<Appender 3...>
<Appenders>
This works but i would like to add more appenders after the include
<Configuration xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
status="warn" name="XMLConfigTest" packages="com.patternconverters">
<xi:include href="default-appenders.xml"/>
<Loggers>
<root level="ERROR">
<appender-ref ref="LOG_ASYNC"/>
</root>
</Loggers>
</Configuration>
Since log4J2 only allows one "Appenders" element to be defined I need a way to do the include that only returns the child elements.
I have tried
<xi:include href="appenders.xml" xpointer="xpointer(//Appenders/*)"/>
and other combinations of using xpointer, but get the error that the xpointer scheme is unsupported.
Is there a way to get this functionality with the element scheme? So far i have only been able to include a specific element using element(/1/n) where n is the position of the element.
Is there another way to get this functionality in xml supported by log4j2(uses the Apache Xerces parser i believe)?
UPDATE:
After much research i was unable to find a native solution of xerces/log4j2. The two available alternatives i've found are to use a third party preprocessor that supports XPointer scheme includes or to extend/rewrite log4j2 XMLConfiguration to support multiple config files. Neither are a viable option for me at this time.