EventLogAppender ClassApache log4net™ SDK Documentation
Writes events to the system event log.
Inheritance Hierarchy

SystemObject
  log4net.AppenderAppenderSkeleton
    log4net.AppenderEventLogAppender

Namespace: log4net.Appender
Assembly: log4net (in log4net.dll) Version: 2.0.6.0-.NET 4.0
Syntax

public class EventLogAppender : AppenderSkeleton

The EventLogAppender type exposes the following members.

Constructors

  NameDescription
Public methodEventLogAppender
Initializes a new instance of the EventLogAppender class.
Public methodEventLogAppender(ILayout) Obsolete.
Initializes a new instance of the EventLogAppender class with the specified ILayout.
Top
Properties

  NameDescription
Public propertyApplicationName
Property used to set the Application name. This appears in the event logs when logging.
Public propertyCategory
Gets or sets the Category to use unless one is explicitly specified via the LoggingEvent's properties.
Public propertyErrorHandler
Gets or sets the IErrorHandler for this appender.
(Inherited from AppenderSkeleton.)
Public propertyEventId
Gets or sets the EventId to use unless one is explicitly specified via the LoggingEvent's properties.
Public propertyFilterHead
The filter chain.
(Inherited from AppenderSkeleton.)
Public propertyLayout
Gets or sets the ILayout for this appender.
(Inherited from AppenderSkeleton.)
Public propertyLogName
The name of the log where messages will be stored.
Public propertyMachineName
This property is used to return the name of the computer to use when accessing the event logs. Currently, this is the current computer, denoted by a dot "."
Public propertyName
Gets or sets the name of this appender.
(Inherited from AppenderSkeleton.)
Protected propertyRequiresLayout
This appender requires a log4net.Layout to be set.
(Overrides AppenderSkeletonRequiresLayout.)
Public propertySecurityContext
Gets or sets the SecurityContext used to write to the EventLog.
Public propertyThreshold
Gets or sets the threshold Level of this appender.
(Inherited from AppenderSkeleton.)
Top
Methods

  NameDescription
Public methodActivateOptions
Initialize the appender based on the options set
(Overrides AppenderSkeletonActivateOptions.)
Public methodAddFilter
Adds a filter to the end of the filter chain.
(Inherited from AppenderSkeleton.)
Public methodAddMapping
Add a mapping of level to EventLogEntryType - done by the config file
Protected methodAppend(LoggingEvent)
Append a bulk array of logging events.
(Inherited from AppenderSkeleton.)
Protected methodAppend(LoggingEvent)
This method is called by the DoAppend(LoggingEvent) method.
(Overrides AppenderSkeletonAppend(LoggingEvent).)
Public methodClearFilters
Clears the filter list for this appender.
(Inherited from AppenderSkeleton.)
Public methodClose
Closes the appender and release resources.
(Inherited from AppenderSkeleton.)
Public methodDoAppend(LoggingEvent)
Performs threshold checks and invokes filters before delegating actual logging to the subclasses specific [M:Append(LoggingEvent)] method.
(Inherited from AppenderSkeleton.)
Public methodDoAppend(LoggingEvent)
Performs threshold checks and invokes filters before delegating actual logging to the subclasses specific [M:Append(LoggingEvent[])] method.
(Inherited from AppenderSkeleton.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFilterEvent
Test if the logging event should we output by this appender
(Inherited from AppenderSkeleton.)
Protected methodFinalize
Finalizes this appender by calling the implementation's Close method.
(Inherited from AppenderSkeleton.)
Public methodFlush
Flushes any buffered log data.
(Inherited from AppenderSkeleton.)
Protected methodGetEntryType
Get the equivalent EventLogEntryType for a Levellevel
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodIsAsSevereAsThreshold
Checks if the message level is below this appender's threshold.
(Inherited from AppenderSkeleton.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnClose
Is called when the appender is closed. Derived classes should override this method if resources need to be released.
(Inherited from AppenderSkeleton.)
Protected methodPreAppendCheck
Called before [M:Append(LoggingEvent)] as a precondition.
(Inherited from AppenderSkeleton.)
Protected methodRenderLoggingEvent(LoggingEvent)
Renders the LoggingEvent to a string.
(Inherited from AppenderSkeleton.)
Protected methodRenderLoggingEvent(TextWriter, LoggingEvent)
Renders the LoggingEvent to a string.
(Inherited from AppenderSkeleton.)
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Top
Remarks

The appender will fail if you try to write using an event source that doesn't exist unless it is running with local administrator privileges. See also http://logging.apache.org/log4net/release/faq.html#trouble-EventLog

The EventID of the event log entry can be set using the EventID property (Properties) on the LoggingEvent.

The Category of the event log entry can be set using the Category property (Properties) on the LoggingEvent.

There is a limit of 32K characters for an event log message

When configuring the EventLogAppender a mapping can be specified to map a logging level to an event log entry type. For example:

<mapping>
  <level value="ERROR" />
  <eventLogEntryType value="Error" />
</mapping>
<mapping>
  <level value="DEBUG" />
  <eventLogEntryType value="Information" />
</mapping>

The Level is the standard log4net logging level and eventLogEntryType can be any value from the EventLogEntryType enum, i.e.:

  • Error - an error event
  • Warning - a warning event
  • Information - an informational event

See Also

Reference