ramanathan1504 commented on code in PR #4070:
URL: https://github.com/apache/logging-log4j2/pull/4070#discussion_r3071271629
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java:
##########
@@ -300,10 +300,16 @@ public LoggerContext getContext(
final boolean currentContext,
final List<URI> configLocations,
final String name) {
- final LoggerContext ctx =
- selector.getContext(fqcn, loader, currentContext, null /*this
probably needs to change*/);
- if (externalContext != null && ctx.getExternalContext() == null) {
- ctx.setExternalContext(externalContext);
+ final LoggerContext ctx;
+ if (externalContext instanceof Map.Entry) {
Review Comment:
@vy
The externalContext is passed as a Map.Entry<String, Object> from the
log4j-web module.
In Log4jWebInitializerImpl.java (lines 177 and 183), it calls:
WebLoggerContextUtils.createExternalEntry(this.servletContext)
This returns the Map.Entry which is then passed through
Configurator.initialize(...) down to the Log4jContextFactory.
I used instanceof Map.Entry in the Factory to ensure that when composite
configurations are used, the externalContext is correctly unwrapped and set so
that WebLookup can find the ServletContext. However, I'm open to moving this
logic to Configurator or elsewhere if you feel the Factory should remain
agnostic of this wrapper.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]