You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2020/02/15 23:15:25 UTC

[logging-log4j2] 01/02: call #StatusLogger.getLogger() only when it's needed. (#300)

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

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

commit 2fb5fed52221f377c0f7db695de69da314783c28
Author: qxo <qx...@gmail.com>
AuthorDate: Sun Feb 16 07:07:43 2020 +0800

    call #StatusLogger.getLogger() only when it's needed. (#300)
    
    when Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED=true should not invoke #StatusLogger.getLogger() in Log4jServletContainerInitializer
    Otherwise there will be initialization issue: custom config issue
---
 .../apache/logging/log4j/web/Log4jServletContainerInitializer.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jServletContainerInitializer.java b/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jServletContainerInitializer.java
index aad1b63..19ac246 100644
--- a/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jServletContainerInitializer.java
+++ b/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jServletContainerInitializer.java
@@ -34,14 +34,14 @@ import org.apache.logging.log4j.status.StatusLogger;
  */
 public class Log4jServletContainerInitializer implements ServletContainerInitializer {
 
-    private static final Logger LOGGER = StatusLogger.getLogger();
-
     @Override
     public void onStartup(final Set<Class<?>> classes, final ServletContext servletContext) throws ServletException {
         if (servletContext.getMajorVersion() > 2 && servletContext.getEffectiveMajorVersion() > 2 &&
                 !"true".equalsIgnoreCase(servletContext.getInitParameter(
                         Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED
                 ))) {
+            final Logger LOGGER = StatusLogger.getLogger();
+
             LOGGER.debug("Log4jServletContainerInitializer starting up Log4j in Servlet 3.0+ environment.");
 
             final FilterRegistration.Dynamic filter =