The Following sample code helps to Read Data from Event Log. This is a sample windows application written by using C#.
In the following sample code, I used 2 controls, Listbox and EventLog Controls.
Set the Log Property of Eventlog control to name of the log to read or write. I selected System Log to test this code
In the Form Load Event, I written the following code,
foreach (System.Diagnostics.EventLogEntry entry in eventLog1.Entries)
{
listBox1.Items.Add(entry.EntryType.ToString() + " - " + entry.TimeWritten + " - " + entry.Source + " - " + entry.UserName);
}
This code, read the Data from Log file and written display in to listbox control.Now if run the code, it will display as shown in screen shot