[
https://issues.apache.org/jira/browse/LOG4J2-1721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17898291#comment-17898291
]
Claudia Pastor Ramirez commented on LOG4J2-1721:
------------------------------------------------
Hello,
I am adding some extra information I have managed to collect activating the
Debug for the log4j2 at on the Tomcat JAVA_OPTS. It seems that when there are
two files, they are found, but nothing happens with them. These are the traces
of the start-up with two configuration files:
!TwoConfigurationFiles.png!
It declares that has found them, but does nothing with them. Goes ahead with
the anchors for an external library I have as a dependency. No logs are printed
anywere (nor on the Tomcat output or the log4j2 declared ones).
When I declare a single file instead, it triggers a reconfiguration using it,
like this:
!OneConfigurationFile.png!
The external library anchors are detected too, but before reaching that point
there are like a hundred of traces about building pluggings ,creating filters,
setting strategies, etc, etc (the expected). And, of course, the application
traces are normally printed.
Thanks a lot for your help!
> 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
>
> Attachments: OneConfigurationFile.png, TwoConfigurationFiles.png,
> image-2024-11-14-14-58-00-645.png
>
> 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)