EventLog.GetEventLogs Method ()

 

Searches for all event logs on the local computer and creates an array of EventLog objects that contain the list.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

static member GetEventLogs : unit -> EventLog[]

Return Value

Type: System.Diagnostics.EventLog[]

An array of type EventLog that represents the logs on the local computer.

Exception Condition
SystemException

You do not have read access to the registry.

-or-

There is no event log service on the computer.

The array of EventLog objects is a snapshot of all event logs on the local computer when the call to GetEventLogs is made. This is not a dynamic collection, so it does not reflect the deletion or creation of logs in real time. You should verify that a log in the array exists before you read or write to it. The array usually includes at least three logs: Application, System, and Security. If you created custom logs on the local computer, they will appear in the array as well.

To retrieve the list of event logs, you must have the appropriate registry permissions. These permissions are identical to those required to call Exists and SourceExists.

The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log.

No code example is currently available or this language may not be supported.

EventLogPermission

for administering event log information on the computer. Associated enumeration: EventLogPermissionAccess.Administer

.NET Framework
Available since 1.1
Return to top
Show: