We know that. net Framework provides the EventLog class to write Windows event logs. The method is very simple. You must first create an EventLog object to interact with Windows event logs. You can specify the log category when creating the event, for example, the following statement creates an applicationProgram"EventLog object associated with the log:
EventLog browserlog = new EventLog ("application ");
Next, you can filter the following log information that you are interested in. The method is simple, by specifying the log Source:
Browserlog. Source = g_selfserviceappname;
If you want to traverse all the log information of the same source, you can use the eventlogentry object, which represents a log information. We can traverse it like this:
Foreach (eventlogentry logentry in browserlog. Entries)
{
......
}
Finally, we can write log information:
Browserlog. writeentry ("message", eventlogentrytype. information );
As you can see, it's so easy to interact with Windows logs!