[
https://issues.apache.org/jira/browse/LOG4J2-1721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17897999#comment-17897999
]
Claudia Pastor Ramirez edited comment on LOG4J2-1721 at 11/13/24 5:24 PM:
--------------------------------------------------------------------------
Hello,
This feature is in theory Resolved since version **
[2.11.1|https://issues.apache.org/jira/issues/?jql=project+%3D+LOG4J2+AND+fixVersion+%3D+2.11.1]
, but I am currently using 2.24.1 and I am unable to make it work. I do not
know if the fix was lost or I have not understood correctly how to use it. I
have added a second URI separated by a comma to my the context-param of name
_log4jConfiguration_ on my web.xml. They both are absolute URIs to files
outside my war. It was working with only one, but it fails to find both when
added the second. This is an example:
{code:java}
<!--original parameter (working)-->
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:///opt/proyect/conf/log4j2.xml</param-value>
</context-param>
<!--composite configuration attempt (finds none)-->
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:///opt/proyect/conf/log4j2.xml,file://opt/proyect/conf/log4j2-env.xml</param-value>
</context-param> {code}
Any help or direction would be really appreciated.
was (Author: cpr):
Hello,
This feature is in theory Resolved since version **
[2.11.1|https://issues.apache.org/jira/issues/?jql=project+%3D+LOG4J2+AND+fixVersion+%3D+2.11.1]
, but I am currently using 2.24.1 and I am unable to make it work. I do not
know if the fix was lost or I have not understood correclty how to use it. I
have added a second URI separated by a comma to my the context-param of name
_log4jConfiguration_ on my web.xml. They both are absolute URIs to files
outside my war. It was working with only one, but it fails to find both when
added the second. This is an example:
{code:java}
<!--original parameter (working)-->
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:///opt/proyect/conf/log4j2.xml</param-value>
</context-param>
<!--composite configuration attempt (finds none)-->
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:///opt/proyect/conf/log4j2.xml,file://opt/proyect/conf/log4j2-env.xml</param-value>
</context-param> {code}
Any help or direction would be really appreciated.
> Composite configuration using log4jConfiguration context parameter
> ------------------------------------------------------------------
>
> Key: LOG4J2-1721
> URL: https://issues.apache.org/jira/browse/LOG4J2-1721
> Project: Log4j 2
> Issue Type: Improvement
> Components: Configurators, Web/Servlet
> Affects Versions: 2.7
> Reporter: Pastrie
> Priority: Major
> Labels: features
> Fix For: 2.11.1
>
> Original Estimate: 3h
> Remaining Estimate: 3h
>
> Log4j allows multiple configuration files to be used by specifying them as a
> list of comma separated file paths on log4j.configurationFile property. This
> feature is not available in web environment since the log4jConfiguration
> context parameter accepts a single Path/File/URI.
> My proposal is to apply some small changes in the Log4jWebInitializerImpl
> class
> - change method getConfigURI to return List<URI> instead of URI.
> {code:title=Log4jWebInitializerImpl.java|borderStyle=solid}
> if (configLocation != null) {
> if (configLocation.contains(",")) {
> final String[] parts = configLocation.split(",");
> final List<URI> uris = new ArrayList<>(parts.length);
> for (final String part : parts) {
> final URL url = servletContext.getResource(part);
> if (url != null) {
> final URI uri = url.toURI();
> LOGGER.debug("getConfigURI found resource [{}]
> in servletContext at [{}]", uri, configLocation);
> uris.add(url);
> }
> }
> }
> {code}
> - change method initializeNonJndi
> {code:title=Log4jWebInitializerImpl.java|borderStyle=solid}
> [...]
> final List<URI> listUri = getConfigURI(location);
> this.loggerContext = Configurator.initialize(this.name,
> this.getClassLoader(), listUri, this.servletContext);
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)