Assembly: System (in System.dll)
The property determines whether the EventLog raises events when entries are written to the log. When the property is true, components that receive the EntryWritten event will receive notification any time an entry is written to the log that is specified in the Log property. If is false, no events are raised.
You can receive event notifications only when entries are written on the local computer. You cannot receive notifications for entries written on remote computers.
The following example handles an EntryWritten event.
Option Strict Option Explicit Imports System Imports System.Diagnostics Imports System.Threading Class MySample Public Shared Sub Main() Dim myNewLog As New EventLog() myNewLog.Log = "MyCustomLog" AddHandler myNewLog.EntryWritten, AddressOf MyOnEntryWritten myNewLog.EnableRaisingEvents = True Console.WriteLine("Press 'q' to quit.") ' Wait for the EntryWrittenEvent or a quit command. While Char.ToLower(Convert.ToChar(Console.Read()))<>"q" ' Wait. End While End Sub ' Main Public Shared Sub MyOnEntryWritten(source As Object, e As EntryWrittenEventArgs) Console.WriteLine(("Written: " + e.Entry.Message)) End Sub ' MyOnEntryWritten End Class ' MySample
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.