nicko 2005/04/16 16:42:42
Modified: src/Appender BufferingAppenderSkeleton.cs
Log:
Fix LOG4NET-24. Programmatic flush of BufferingAppenderSkeleton buffer
Revision Changes Path
1.9 +37 -1 logging-log4net/src/Appender/BufferingAppenderSkeleton.cs
Index: BufferingAppenderSkeleton.cs
===================================================================
RCS file:
/home/cvs/logging-log4net/src/Appender/BufferingAppenderSkeleton.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BufferingAppenderSkeleton.cs 17 Jan 2005 20:18:41 -0000 1.8
+++ BufferingAppenderSkeleton.cs 16 Apr 2005 23:42:42 -0000 1.9
@@ -257,6 +257,42 @@
#endregion Public Instance Properties
+ #region Public Methods
+
+ /// <summary>
+ /// Flush the currently buffered events
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Flushes any events that have been buffered.
+ /// </para>
+ /// <para>
+ /// If the appender is buffering in <see cref="Lossy"/> mode
then the contents
+ /// of the buffer will NOT be flushed to the appender.
+ /// </para>
+ /// </remarks>
+ public virtual void Flush()
+ {
+ // This method will be called outside of the
AppenderSkeleton DoAppend() method
+ // therefore it needs to be protected by its own lock.
This will block any
+ // Appends while the buffer is flushed.
+ lock(this)
+ {
+ // Do nothing if the buffer does not exist, or
we are not configured
+ // to buffer events, or if the buffer is full
of lossy events (the
+ // evaluator should flush the buffer each time
a significant event arrives).
+ // NOTE that there is an issue here with the
m_lossyEvaluator which
+ // may trigger for some of the events in the
lossy buffer, which we should
+ // really be checking for.
+ if (m_cb != null && m_bufferSize > 1 &&
!m_lossy)
+ {
+ SendBuffer(m_cb);
+ }
+ }
+ }
+
+ #endregion Public Methods
+
#region Implementation of IOptionHandler
/// <summary>
@@ -408,7 +444,7 @@
SendBuffer(m_cb);
}
}
- }
+ }
#endregion Override implementation of AppenderSkeleton