This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/release-2.x by this push:
     new 80aae21796 [LOG4J2-3577] Use classloader provided by servlet context
80aae21796 is described below

commit 80aae217962109e86e7edba0f87a266b989fce37
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Thu Aug 18 17:23:43 2022 +0200

    [LOG4J2-3577] Use classloader provided by servlet context
    
    Since we advertise a Servlet 4.0 requirement, we can use
    `ServletContext#getClassLoader()` from Servlet 3.0 to retrieve the
    correct logger context for the given servlet context.
---
 .../java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java
 
b/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java
index 32b08c4040..32535c14af 100644
--- 
a/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java
+++ 
b/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java
@@ -163,13 +163,13 @@ final class Log4jWebInitializerImpl extends 
AbstractLifeCycle implements Log4jWe
         }
         if (location != null && location.contains(",")) {
             final List<URI> uris = getConfigURIs(location);
-            this.loggerContext = Configurator.initialize(this.name, 
this.getClassLoader(), uris,
+            this.loggerContext = Configurator.initialize(this.name, 
servletContext.getClassLoader(), uris,
                     
WebLoggerContextUtils.createExternalEntry(this.servletContext));
             return;
         }
 
         final URI uri = getConfigURI(location);
-        this.loggerContext = Configurator.initialize(this.name, 
this.getClassLoader(), uri,
+        this.loggerContext = Configurator.initialize(this.name, 
servletContext.getClassLoader(), uri,
                 
WebLoggerContextUtils.createExternalEntry(this.servletContext));
     }
 

Reply via email to