System.Diagnostics.EventLog.EntryWritten Event

Occurs when an entry is written to an event log on the local computer.


[System.Diagnostics.MonitoringDescription("Raised for each EventLog entry written.")]
public event EntryWrittenEventHandler EntryWritten


To get event notifications, you must set EventLog.EnableRaisingEvents to true. You can only receive event notifications when entries are written on the local computer. You cannot receive notifications for entries written on remote computers.

When you create an EventLog.EntryWritten delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, until you remove the delegate. For more information about handling events with delegates, see Consuming Events.

The system responds to erload:System.Diagnostics.EventLog.WriteEntry only if the last write event occurred at least six seconds previously. This implies you will only receive one EventLog.EntryWritten event notification within a six-second interval, even if more than one event log change occurs. If you insert a sufficiently long sleep interval (around 10 seconds) between calls to erload:System.Diagnostics.EventLog.WriteEntry, you are less likely to miss an event. However, if write events occur more frequently, you might not recieve the event notification until the next interval. Typically, missed event notifications are not lost, but delayed.


Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0,,