You use the Entries collection to look at the entries in a particular event log. You can use standard collection properties such as All, Count, and Item to work with the elements the collection contains. You might read event log entries to find out more information about a problem that occurred in your system, to identify usage patterns, or to identify problems (such as a failing hard drive) before they cause damage.
Note The Entries collection is read-only; to write a message to a log you must use the WriteEntry method. For information, see Writing Entries to Event Logs .
If you ask for the count of entries in a new custom log that has not yet been written to, the system will return the count of the entries in the Application log on that server. Make sure that logs you are counting have been created and written to in order to avoid this problem.
To read event log entries
The resulting code might look like the following:
[Visual Basic] Dim en As EventLogEntry For Each en In EventLog1.Entries Debug.Print en.Message Next en Dim enArr() As EventLogEntry EnArr = EventLog1.Entries.All [C#] EventLogEntry en; EventLogEntry[] enArr; foreach (en in EventLog1.Entries) { Debug.Print en.Message; } EnArr = EventLog1.Entries.All;
Introduction to the EventLog Component | Handling the EntryWritten Event