Using the EventLog Class in VB.net

By: Steven Holzner Emailed: 1785 times Printed: 2623 times    

The EventLog class supports access to Windows event logs from Windows services. Here is the inheritance hierarchy of this class:

Object
   MarshalByRefObject
      Component
         EventLog

You can find the more notable public class methods of EventLog in Table 3, the more notable public properties of EventLog objects in Table 4, their more notable methods in Table 5, and their more notable events in Table 6.

Table 3: Noteworthy public class (shared) methods of the EventLog class.

Method

Means

CreateEventSource

Enables an application to write event data to a log.

Delete

Removes a log.

DeleteEventSource

Removes an application's event source registration.

Exists

Indicates if a log exists.

GetEventLogs

Returns an array of event logs.

LogNameFromSourceName

Gets the name of the log a source is registered with.

SourceExists

Checks for a specific event source.

WriteEntry

Writes an entry in the log.

Table 4: Noteworthy public properties of EventLog objects.

Property

Means

EnableRaisingEvents

Gets/sets if the event log gets EntryWritten events.

Entries

Gets the contents of the log.

Log

Gets/sets the name of the log.

LogDisplayName

Gets the log's display name.

MachineName

Gets/sets the name of the log's computer.

Source

Gets/sets the source name to use when writing to the log.

Table 5: Noteworthy public methods of EventLog objects.

Method

Means

BeginInit

Begins the initialization operation of an event log.

Clear

Clears all entries from the log.

Close

Closes the log.

EndInit

Ends the initialization operation of an event log.

WriteEntry

Writes an entry in the event log.

Table 6: Noteworthy public events of EventLog objects.

Event

Means

EntryWritten

Occurs when data is written to an event log.

Most Viewed Articles (in VB.net )

Latest Articles (in VB.net)

Comment on this tutorial