Table of Contents

Class CyclicBuffer

Namespace
log4net.Util
Assembly
log4net.dll

A fixed size rolling buffer of logging events.

public class CyclicBuffer
Inheritance
CyclicBuffer
Inherited Members

Remarks

An array backed fixed size leaky bucket.

Constructors

CyclicBuffer(int)

Constructor

public CyclicBuffer(int maxSize)

Parameters

maxSize int

The maximum number of logging events in the buffer.

Remarks

Initializes a new instance of the CyclicBuffer class with the specified maximum number of buffered logging events.

Exceptions

ArgumentOutOfRangeException

The maxSize argument is not a positive integer.

Properties

this[int]

Gets the ith oldest event currently in the buffer.

public LoggingEvent? this[int i] { get; }

Parameters

i int

Property Value

LoggingEvent

Remarks

If i is outside the range 0 to the number of events currently in the buffer, then null is returned.

Length

Gets the number of logging events in the buffer.

public int Length { get; }

Property Value

int

The number of logging events in the buffer.

Remarks

This number is guaranteed to be in the range 0 to MaxSize (inclusive).

MaxSize

Gets the maximum size of the buffer.

public int MaxSize { get; }

Property Value

int

The maximum size of the buffer.

Remarks

Gets the maximum size of the buffer

Methods

Append(LoggingEvent)

Appends a loggingEvent to the buffer.

public LoggingEvent? Append(LoggingEvent loggingEvent)

Parameters

loggingEvent LoggingEvent

The event to append to the buffer.

Returns

LoggingEvent

The event discarded from the buffer, if the buffer is full, otherwise null.

Remarks

Append an event to the buffer. If the buffer still contains free space then null is returned. If the buffer is full then an event will be dropped to make space for the new event, the dropped event is returned.

Clear()

Clear the buffer

public void Clear()

Remarks

Clear the buffer of all events. The events in the buffer are lost.

PopAll()

Pops all the logging events from the buffer into an array.

public LoggingEvent[] PopAll()

Returns

LoggingEvent[]

An array of all the logging events in the buffer.

Remarks

Get all the events in the buffer and clear the buffer.

PopOldest()

Get and remove the oldest event in the buffer.

public LoggingEvent? PopOldest()

Returns

LoggingEvent

The oldest logging event in the buffer

Remarks

Gets the oldest (first) logging event in the buffer and removes it from the buffer.