in src/log4net/Appender/BufferingAppenderSkeleton.cs [250:298]
public virtual void Flush(bool flushLossyBuffer)
{
// This method will be called outside 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 (LockObj)
{
if (_cyclicBuffer is not null && _cyclicBuffer.Length > 0)
{
if (Lossy)
{
// If we are allowed to eagerly flush from the lossy buffer
if (flushLossyBuffer)
{
if (LossyEvaluator is not null)
{
// Test the contents of the buffer against the lossy evaluator
LoggingEvent[] bufferedEvents = _cyclicBuffer.PopAll();
var filteredEvents = new List<LoggingEvent>(bufferedEvents.Length);
foreach (LoggingEvent loggingEvent in bufferedEvents)
{
if (LossyEvaluator.IsTriggeringEvent(loggingEvent))
{
filteredEvents.Add(loggingEvent);
}
}
// Send the events that meet the lossy evaluator criteria
if (filteredEvents.Count > 0)
{
SendBuffer(filteredEvents.ToArray());
}
}
else
{
// No lossy evaluator, all buffered events are discarded
_cyclicBuffer.Clear();
}
}
}
else
{
// Not lossy, send whole buffer
SendFromBuffer(null, _cyclicBuffer);
}
}
}
}