I have a web app and it has some dependent jars (one of them is a rest client). My scenario is this. I have a log4j2-cswc.xml defined in the rest client dependent jar and is supposed to write the logs to a separate rolling file. In the web app, I have a log4j2.xml defined.
Composite configuration says we have to specify the list of separated file paths on log4j.configurationFile system property. In case if I do not want to use the system property, the equivalent of using a context parameter in the web.xml is log4jConfiguration.
Now I tried to declare the log4jConfiguration context-param
as below.
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>/WEB-INF/classes/log4j2.xml,classpath:log4j2-cwsc.xml</param-value>
</context-param>
Even though, it shows the below log entry that it is starting the LoggerContext,
DEBUG Starting LoggerContext[name=XYZ] from configuration at file:/WEB-INF/classes/log4j2.xml,classpath:log4j2-cwsc.xml
it is only loading the log4j2.xml of the web app (as you would notice in the following log) and ignores the rest client dependent log4j2-cwsc.xml following the explanation here. My expectation based on the composite configuration is that it would merge both the configurations.
DEBUG Starting LoggerContext[name=XYZ, org.apache.logging.log4j.core.LoggerContext@9e8a94] with configuration XmlConfiguration[location=/apps/v85/WebSphere/wp_profile/installedApps/node1/PA_XYZ.ear/XYZ-17.0.6-SNAP.war/WEB-INF/classes/log4j2.xml]
So what is correct way to declare the composite configuration to include the log4j2 configuration from a dependent jar in a web.xml file? Note: I am using log4j2 v2.8.2
Thanks.