How to traverse windows Event Logs

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.