Table of Contents

Class MemoryAppender

Namespace
log4net.Appender
Assembly
log4net.dll

Stores logging events in an array.

public class MemoryAppender : AppenderSkeleton, IBulkAppender, IAppender, IOptionHandler, IFlushable
Inheritance
MemoryAppender
Implements
Inherited Members

Remarks

The memory appender stores all the logging events that are appended in an in-memory array.

Use the PopAllEvents() method to get and clear the current list of events that have been appended.

Use the GetEvents() method to get the current list of events that have been appended. Note there is a race-condition when calling GetEvents() and Clear() in pairs, you better use in that case.

Use the Clear() method to clear the current list of events. Note there is a race-condition when calling GetEvents() and Clear() in pairs, you better use in that case.

Constructors

MemoryAppender()

Initializes a new instance of the MemoryAppender class.

public MemoryAppender()

Remarks

Default constructor.

Fields

m_eventsList

The list of events that have been appended.

protected ArrayList m_eventsList

Field Value

ArrayList

m_fixFlags

Value indicating which fields in the event should be fixed

protected FixFlags m_fixFlags

Field Value

FixFlags

Remarks

By default all fields are fixed

Properties

Fix

Gets or sets the fields that will be fixed in the event

public virtual FixFlags Fix { get; set; }

Property Value

FixFlags

Remarks

The logging event needs to have certain thread specific values captured before it can be buffered. See Fix for details.

OnlyFixPartialEventData

Gets or sets a value indicating whether only part of the logging event data should be fixed.

[Obsolete("Use Fix property")]
public virtual bool OnlyFixPartialEventData { get; set; }

Property Value

bool

true if the appender should only fix part of the logging event data, otherwise false. The default is false.

Remarks

Setting this property to true will cause only part of the event data to be fixed and stored in the appender, hereby improving performance.

See LoggingEvent.FixVolatileData(bool) for more information.

Methods

Append(LoggingEvent)

This method is called by the AppenderSkeleton.DoAppend(LoggingEvent) method.

protected override void Append(LoggingEvent loggingEvent)

Parameters

loggingEvent LoggingEvent

the event to log

Remarks

Stores the loggingEvent in the events list.

Clear()

Clear the list of events

public virtual void Clear()

Remarks

Clear the list of events

GetEvents()

Gets the events that have been logged.

public virtual LoggingEvent[] GetEvents()

Returns

LoggingEvent[]

The events that have been logged

Remarks

Gets the events that have been logged.

PopAllEvents()

Gets the events that have been logged and clears the list of events.

public virtual LoggingEvent[] PopAllEvents()

Returns

LoggingEvent[]

The events that have been logged

Remarks

Gets the events that have been logged and clears the list of events.