EventLog.GetEventLogs Method (String)
Searches for all event logs on the given computer and creates an array of EventLog objects that contain the list.
Assembly: System (in System.dll)
'Declaration Public Shared Function GetEventLogs ( _ machineName As String _ ) As EventLog()
- Type: System.String
The computer on which to search for event logs.
The array of EventLog objects is a snapshot of all event logs on the computer specified by the machineName parameter 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 specified computer, they will appear in the array as well.
The following example gets a list of logs on the computer "myServer". It then outputs the name of each log.
Imports System Imports System.Diagnostics Imports System.Threading Class MySample Public Shared Sub Main() Dim remoteEventLogs() As EventLog remoteEventLogs = EventLog.GetEventLogs("myServer") Console.WriteLine(("Number of logs on computer: " & remoteEventLogs.Length)) Dim log As EventLog For Each log In remoteEventLogs Console.WriteLine(("Log: " & log.Log)) Next log End Sub ' Main End Class ' MySample
Windows 8.1, Windows Server 2012 R2, 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.