logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1477462 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/async/ core/src/main/java/org/apache/logging/log4j/core/config/ samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/ src/changes/
Date Tue, 30 Apr 2013 03:48:13 GMT
Author: rgoers
Date: Tue Apr 30 03:48:13 2013
New Revision: 1477462

URL: http://svn.apache.org/r1477462
Log:
LOG4J2-222 - Disruptor will now shutdown during Tomcat shutdown.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
    logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java?rev=1477462&r1=1477461&r2=1477462&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
Tue Apr 30 03:48:13 2013
@@ -80,7 +80,7 @@ public class AsyncLoggerConfig extends L
 
     /**
      * Constructor that sets the name, level and additive values.
-     * 
+     *
      * @param name The Logger name.
      * @param level The Level.
      * @param additive true if the Logger is additive, false otherwise.
@@ -128,19 +128,19 @@ public class AsyncLoggerConfig extends L
 
     @Override
     public void stopFilter() {
-        // only stop disruptor if shutting down logging subsystem
+        /* only stop disruptor if shutting down logging subsystem
         if (LogManager.getContext() instanceof LoggerContext) {
             if (((LoggerContext) LogManager.getContext()).getStatus() != Status.STOPPING)
{
                 return;
             }
-        }
+        } */
         helper.shutdown();
         super.stopFilter();
     }
 
     /**
      * Factory method to create a LoggerConfig.
-     * 
+     *
      * @param additivity True if additive, false otherwise.
      * @param levelName The Level to be associated with the Logger.
      * @param loggerName The name of the Logger.

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java?rev=1477462&r1=1477461&r2=1477462&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
Tue Apr 30 03:48:13 2013
@@ -63,8 +63,9 @@ class AsyncLoggerConfigHelper {
     private static final Logger LOGGER = StatusLogger.getLogger();
 
     private static volatile Disruptor<RingBufferLog4jEvent> disruptor;
-    private static ExecutorService executor = Executors
-            .newSingleThreadExecutor();
+    private static ExecutorService executor = Executors.newSingleThreadExecutor();
+
+    private static volatile int count = 0;
 
     /**
      * Factory used to populate the RingBuffer with events. These event objects
@@ -97,6 +98,7 @@ class AsyncLoggerConfigHelper {
     }
 
     private static synchronized void initDisruptor() {
+        ++count;
         if (disruptor != null) {
             return;
         }
@@ -213,7 +215,10 @@ class AsyncLoggerConfigHelper {
         }
     }
 
-    public void shutdown() {
+    public synchronized void shutdown() {
+        if (--count > 0) {
+            return;
+        }
         Disruptor<RingBufferLog4jEvent> temp = disruptor;
 
         // Must guarantee that publishing to the RingBuffer has stopped

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java?rev=1477462&r1=1477461&r2=1477462&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
Tue Apr 30 03:48:13 2013
@@ -136,15 +136,16 @@ public class BaseConfiguration extends A
      */
     @Override
     public void stop() {
-        for (final LoggerConfig logger : loggers.values()) {
-            logger.clearAppenders();
-            logger.stopFilter();
-        }
         // Stop the appenders in reverse order in case they still have activity.
         final Appender[] array = appenders.values().toArray(new Appender[appenders.size()]);
         for (int i = array.length - 1; i >= 0; --i) {
             array[i].stop();
         }
+        for (final LoggerConfig logger : loggers.values()) {
+            logger.clearAppenders();
+            logger.stopFilter();
+        }
+        root.stopFilter();
         stopFilter();
     }
 

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java?rev=1477462&r1=1477461&r2=1477462&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
Tue Apr 30 03:48:13 2013
@@ -226,6 +226,10 @@ public class XMLConfiguration extends Ba
 
     @Override
     public void setup() {
+        if (rootElement == null) {
+            LOGGER.error("No logging configuration");
+            return;
+        }
         constructHierarchy(rootNode, rootElement);
         if (status.size() > 0) {
             for (final Status s : status) {

Modified: logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java?rev=1477462&r1=1477461&r2=1477462&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java
(original)
+++ logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java
Tue Apr 30 03:48:13 2013
@@ -50,19 +50,6 @@ public class LoggingController {
 
     private List<AuditEvent> events;
 
-    public LoggingController() {
-
-        ThreadContext.clear();
-
-        RequestContext.setSessionId("session1234");
-        RequestContext.setIpAddress("127.0.0.1");
-        RequestContext.setClientId("02121");
-        RequestContext.setProductName("IB");
-        RequestContext.setProductVersion("4.18.1");
-        RequestContext.setLocale("en_US");
-        RequestContext.setRegion("prod");
-    }
-
     @RequestMapping(value = "/start.do", method = RequestMethod.GET)
     public ModelAndView startLogging(
         @RequestParam(value = "member", required = false, defaultValue = "fakemember") final
String member,
@@ -80,6 +67,15 @@ public class LoggingController {
 
             @Override
             public void run() {
+                ThreadContext.clear();
+
+                RequestContext.setSessionId("session1234");
+                RequestContext.setIpAddress("127.0.0.1");
+                RequestContext.setClientId("02121");
+                RequestContext.setProductName("IB");
+                RequestContext.setProductVersion("4.18.1");
+                RequestContext.setLocale("en_US");
+                RequestContext.setRegion("prod");
                 while (generateLog) {
                     // Generate rand number between 1 to 10
                     final int rand = ran.nextInt(9) + 1;
@@ -110,6 +106,7 @@ public class LoggingController {
                     }
 
                 }
+                ThreadContext.cloneStack();
             }
         }).start();
 

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1477462&r1=1477461&r2=1477462&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Tue Apr 30 03:48:13 2013
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.0-beta6" date="@TBD@" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-222" dev="rgoers" type="fix">
+        Disruptor will now shutdown during Tomcat shutdown.
+      </action>
       <action dev="rpopma" type="update">
         Renamed AsynchAppender to AsyncAppender. Plugin name became Async (was Asynch).
       </action>



Mime
View raw message