EventLogAppender Class | Apache log4net™ SDK Documentation

Writes events to the system event log.
Inheritance Hierarchy

System
Object
log4net.Appender
AppenderSkeleton
log4net.Appender
EventLogAppender

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

C#
VB
C++
F#
Copy

    public class EventLogAppender : AppenderSkeleton

    Public Class EventLogAppender
    	Inherits AppenderSkeleton

    public ref class EventLogAppender : public AppenderSkeleton

    type EventLogAppender =
        class
            inherit AppenderSkeleton
        end

The EventLogAppender type exposes the following members.

Constructors

| Name | Description
--- | --- | ---
| EventLogAppender | Initializes a new instance of the EventLogAppender class.
| EventLogAppender(ILayout) | Obsolete. Initializes a new instance of the EventLogAppender class with the specified ILayout.

Top
Properties

| Name | Description
--- | --- | ---
| ApplicationName | Property used to set the Application name. This appears in the event logs when logging.
| Category | Gets or sets the Category to use unless one is explicitly specified via the LoggingEvent's properties.
| ErrorHandler | Gets or sets the IErrorHandler for this appender. (Inherited from AppenderSkeleton.)
| EventId | Gets or sets the EventId to use unless one is explicitly specified via the LoggingEvent's properties.
| FilterHead | The filter chain. (Inherited from AppenderSkeleton.)
| Layout | Gets or sets the ILayout for this appender. (Inherited from AppenderSkeleton.)
| LogName | The name of the log where messages will be stored.
| MachineName | 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 "."
| Name | Gets or sets the name of this appender. (Inherited from AppenderSkeleton.)
| RequiresLayout | This appender requires a log4net.Layout to be set. (Overrides AppenderSkeleton RequiresLayout.)
| SecurityContext | Gets or sets the SecurityContext used to write to the EventLog.
| Threshold | Gets or sets the threshold Level of this appender. (Inherited from AppenderSkeleton.)

Top
Methods

| Name | Description
--- | --- | ---
| ActivateOptions | Initialize the appender based on the options set (Overrides AppenderSkeleton ActivateOptions .)
| AddFilter | Adds a filter to the end of the filter chain. (Inherited from AppenderSkeleton.)
| AddMapping | Add a mapping of level to EventLogEntryType - done by the config file
| Append( LoggingEvent ) | Append a bulk array of logging events. (Inherited from AppenderSkeleton.)
| Append(LoggingEvent) | This method is called by the DoAppend(LoggingEvent) method. (Overrides AppenderSkeleton Append(LoggingEvent).)
| ClearFilters | Clears the filter list for this appender. (Inherited from AppenderSkeleton.)
| Close | Closes the appender and release resources. (Inherited from AppenderSkeleton.)
| DoAppend(LoggingEvent) | Performs threshold checks and invokes filters before delegating actual logging to the subclasses specific [M:Append(LoggingEvent)] method. (Inherited from AppenderSkeleton.)
| DoAppend( LoggingEvent ) | Performs threshold checks and invokes filters before delegating actual logging to the subclasses specific [M:Append(LoggingEvent[])] method. (Inherited from AppenderSkeleton.)
| Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
| FilterEvent | Test if the logging event should we output by this appender (Inherited from AppenderSkeleton.)
| Finalize | Finalizes this appender by calling the implementation's Close method. (Inherited from AppenderSkeleton.)
| Flush | Flushes any buffered log data. (Inherited from AppenderSkeleton.)
| GetEntryType | Get the equivalent EventLogEntryType for a Level level
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
| GetType | Gets the Type of the current instance. (Inherited from Object.)
| IsAsSevereAsThreshold | Checks if the message level is below this appender's threshold. (Inherited from AppenderSkeleton.)
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
| OnClose | Is called when the appender is closed. Derived classes should override this method if resources need to be released. (Inherited from AppenderSkeleton.)
| PreAppendCheck | Called before [M:Append(LoggingEvent)] as a precondition. (Inherited from AppenderSkeleton.)
| RenderLoggingEvent(LoggingEvent) | Renders the LoggingEvent to a string. (Inherited from AppenderSkeleton.)
| RenderLoggingEvent(TextWriter, LoggingEvent) | Renders the LoggingEvent to a string. (Inherited from AppenderSkeleton.)
| ToString | 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:

Copy

    <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

log4net.Appender Namespace