logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1462895 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/appender/AsynchAppender.java src/changes/changes.xml
Date Sun, 31 Mar 2013 08:11:53 GMT
Author: rgoers
Date: Sun Mar 31 08:11:52 2013
New Revision: 1462895

URL: http://svn.apache.org/r1462895
Log:
LOG4J2-188, LOG4J2-189 - appender-refs on AsynchAppender didn't support the level and filter
elements, The blocking parameter did not work properly on AsynchAppender.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AsynchAppender.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AsynchAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AsynchAppender.java?rev=1462895&r1=1462894&r2=1462895&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AsynchAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AsynchAppender.java
Sun Mar 31 08:11:52 2013
@@ -76,7 +76,8 @@ public final class AsynchAppender<T exte
         final List<AppenderControl> appenders = new ArrayList<AppenderControl>();
         for (final AppenderRef appenderRef : appenderRefs) {
             if (map.containsKey(appenderRef.getRef())) {
-                appenders.add(new AppenderControl(map.get(appenderRef.getRef()), null, null));
+                appenders.add(new AppenderControl(map.get(appenderRef.getRef()), appenderRef.getLevel(),
+                    appenderRef.getFilter()));
             } else {
                 LOGGER.error("No appender named {} was configured", appenderRef);
             }
@@ -119,18 +120,21 @@ public final class AsynchAppender<T exte
             throw new IllegalStateException("AsynchAppender " + getName() + " is not active");
         }
         if (event instanceof Log4jLogEvent) {
-            if (blocking && queue.remainingCapacity() > 0) {
+            boolean appendSuccessful = false;
+            if (blocking){
                 try {
-                    queue.add(Log4jLogEvent.serialize((Log4jLogEvent) event));
-                    return;
-                } catch (final IllegalStateException ex) {
-                    error("Appender " + getName() + " is unable to write primary appenders.
queue is full");
+                    queue.put(Log4jLogEvent.serialize((Log4jLogEvent) event)); // wait for
free slots in the queue
+                    appendSuccessful = true;
+                } catch (InterruptedException e) {
+                    LOGGER.warn("Interrupted while waiting for a free slots in the LogEvent-queue
at the AsynchAppender {}", getName());
                 }
-            }
-            if (errorAppender != null) {
-                if (!blocking) {
+            } else {
+                appendSuccessful = queue.offer(Log4jLogEvent.serialize((Log4jLogEvent) event));
+                if (!appendSuccessful) {
                     error("Appender " + getName() + " is unable to write primary appenders.
queue is full");
                 }
+            }
+            if ((!appendSuccessful) && (errorAppender != null)){
                 errorAppender.callAppender(event);
             }
         }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1462895&r1=1462894&r2=1462895&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sun Mar 31 08:11:52 2013
@@ -23,6 +23,12 @@
 
   <body>
     <release version="2.0-beta5" date="@TBD@" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-189" dev="rgoers" type="fix" due-to="Werner">
+        The blocking parameter did not work properly on AsynchAppender.
+      </action>
+      <action issue="LOG4J2-188" dev="rgoers" type="fix" due-to="Werner">
+        appender-refs on AsynchAppender didn't support the level and filter elements.
+      </action>
       <action issue="LOG4J2-176" dev="rgoers" type="fix" due-to="Remko Popma">
         Avoid IllegalArgumentException in AsynchAppender.
       </action>



Mime
View raw message