Gets the contents of the event log.
Assembly: System (in System.dll)
'Declaration <BrowsableAttribute(False)> _ Public ReadOnly Property Entries As EventLogEntryCollection
Use the member when reading from the event log.
Because the property is read-only, you cannot modify an entry or write to the log using . Instead, specify a Source and call WriteEntry to write a new log entry. You can use to count the number of entries in the event log, and view each EventLogEntry in the collection. Use the indexed Item member to retrieve information about a specific entry, such as Message, Category, TimeWritten, or EntryType.
It is not necessary to specify a Source when only reading from a log. You can specify only the Log name and MachineName (server computer name) properties for the EventLog instance. In either case, the member is automatically populated with the event log's list of entries. You can select the appropriate index for an item in this list to read individual entries.
An important distinction between reading and writing log entries is that it is not necessary to explicitly call a read method. After the Log and MachineName are specified, the property is automatically populated. If you change the value of the Log or MachineName property, the property is repopulated the next time you read it.
The following example reads entries in the event log, "MyNewLog", on the local computer.
Option Strict Option Explicit Imports System Imports System.Diagnostics Imports Microsoft.VisualBasic Class MySample Public Shared Sub Main() Dim myLog As New EventLog() myLog.Log = "MyNewLog" Dim entry As EventLogEntry For Each entry In myLog.Entries Console.WriteLine((ControlChars.Tab & "Entry: " & entry.Message)) Next entry End Sub ' Main End Class ' MySample
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.