logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1592429 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
Date Sun, 04 May 2014 23:18:49 GMT
Author: mattsicker
Date: Sun May  4 23:18:49 2014
New Revision: 1592429

URL: http://svn.apache.org/r1592429
Log:
Add check for log4j-web to shutdown hook thread.

  - Don't use shutdown hook if log4j-web is present.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java?rev=1592429&r1=1592428&r2=1592429&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
Sun May  4 23:18:49 2014
@@ -39,6 +39,7 @@ import org.apache.logging.log4j.core.con
 import org.apache.logging.log4j.core.config.NullConfiguration;
 import org.apache.logging.log4j.core.config.Reconfigurable;
 import org.apache.logging.log4j.core.helpers.Assert;
+import org.apache.logging.log4j.core.helpers.Loader;
 import org.apache.logging.log4j.core.helpers.NetUtils;
 import org.apache.logging.log4j.core.jmx.Server;
 import org.apache.logging.log4j.message.MessageFactory;
@@ -54,6 +55,12 @@ import org.apache.logging.log4j.status.S
  */
 public class LoggerContext implements org.apache.logging.log4j.spi.LoggerContext, ConfigurationListener,
LifeCycle {
 
+    static {
+        USING_LOG4J_WEB = Loader.isClassAvailable("org.apache.logging.log4j.web.Log4jWebSupport");
+    }
+
+    private static final boolean USING_LOG4J_WEB;
+
     public static final String PROPERTY_CONFIG = "config";
     private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
     private static final Marker SHUTDOWN_HOOK = MarkerManager.getMarker("SHUTDOWN HOOK");
@@ -186,7 +193,7 @@ public class LoggerContext implements or
     }
 
     private void setUpShutdownHook() {
-        if (config.isShutdownHookEnabled()) {
+        if (config.isShutdownHookEnabled() && !USING_LOG4J_WEB) {
             LOGGER.debug(SHUTDOWN_HOOK, "Shutdown hook enabled. Registering a new one.");
             shutdownThread = new SoftReference<Thread>(
                     new Thread(new ShutdownThread(this), "log4j-shutdown")
@@ -294,7 +301,7 @@ public class LoggerContext implements or
      * Whether this collection is a copy of the underlying collection or not is undefined.
Therefore, modify this collection at your own
      * risk.
      * </p>
-     * 
+     *
      * @return a collection of the current loggers.
      */
     public Collection<Logger> getLoggers() {



Mime
View raw message