Author: carnold
Date: Sun Oct 11 02:53:45 2009
New Revision: 824003

URL: http://svn.apache.org/viewvc?rev=824003&view=rev
Log:
Bug 28647: Allow overriding of flush strategy

Modified:
    logging/log4j/trunk/src/changes/changes.xml
    logging/log4j/trunk/src/main/java/org/apache/log4j/WriterAppender.java

Modified: logging/log4j/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/changes/changes.xml?rev=824003&r1=824002&r2=824003&view=diff
==============================================================================
--- logging/log4j/trunk/src/changes/changes.xml (original)
+++ logging/log4j/trunk/src/changes/changes.xml Sun Oct 11 02:53:45 2009
@@ -87,6 +87,7 @@
        <action action="add" issue="46983">More Debug output for log4j 
auto-configure requested.</action>
        <action action="add" issue="47107">Add MDC.clear().</action>
        <action action="fix" issue="47547">NullPointerException when calling 
Category.removeAllAppenders().</action>
+       <action action="add" issue-"28647">Allow overridding of flush 
strategy.</action>
     </release>
 
   

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/WriterAppender.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/WriterAppender.java?rev=824003&r1=824002&r2=824003&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/WriterAppender.java 
(original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/WriterAppender.java Sun 
Oct 11 02:53:45 2009
@@ -38,7 +38,8 @@
 
   /**
      Immediate flush means that the underlying writer or output stream
-     will be flushed at the end of each append operation. Immediate
+     will be flushed at the end of each append operation unless shouldFlush()
+     is overridden. Immediate
      flush is slower but ensures that each append request is actually
      written. If <code>immediateFlush</code> is set to
      <code>false</code>, then there is a good chance that the last few
@@ -315,7 +316,7 @@
       }
     }
 
-    if(this.immediateFlush) {
+    if(shouldFlush(event)) {
       this.qw.flush();
     }
   }
@@ -369,4 +370,14 @@
        this.qw.write(h);
     }
   }
+  
+  /**
+   * Determines whether the writer should be flushed after
+   * this event is written.
+   * 
+   * @since 1.2.16
+   */
+  protected boolean shouldFlush(final LoggingEvent event) {
+     return immediateFlush();
+  }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to