in src/log4net/Appender/BufferingAppenderSkeleton.cs [314:362]
public virtual void Flush(bool flushLossyBuffer)
{
// 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)
{
if (m_cb != null && m_cb.Length > 0)
{
if (m_lossy)
{
// If we are allowed to eagerly flush from the lossy buffer
if (flushLossyBuffer)
{
if (m_lossyEvaluator != null)
{
// Test the contents of the buffer against the lossy evaluator
LoggingEvent[] bufferedEvents = m_cb.PopAll();
ArrayList filteredEvents = new ArrayList(bufferedEvents.Length);
foreach(LoggingEvent loggingEvent in bufferedEvents)
{
if (m_lossyEvaluator.IsTriggeringEvent(loggingEvent))
{
filteredEvents.Add(loggingEvent);
}
}
// Send the events that meet the lossy evaluator criteria
if (filteredEvents.Count > 0)
{
SendBuffer((LoggingEvent[])filteredEvents.ToArray(typeof(LoggingEvent)));
}
}
else
{
// No lossy evaluator, all buffered events are discarded
m_cb.Clear();
}
}
}
else
{
// Not lossy, send whole buffer
SendFromBuffer(null, m_cb);
}
}
}
}