C # operating system logs using EventLog

Source: Internet
Author: User
First, let's take a look at some concepts of system logs, as shown in:



When writing system logs, you must specify the event source. Then, the system determines the log under which the event source is registered and adds an event to the log. Using the EventLog class, you can easily add an event:

Copy content to clipboardProgramCodeProgram code
EventLog. writeentry ("ABC", "Hello world! ", Eventlogentrytype. Warning); // The default event is under the Application



Next, create a log "Custom Event", register the ABC event source to "Custom Event", and add an event:

Copy the content to the clipboard program code
// The Event source is registered with the event. It is automatically created when the log does not exist.
EventLog. createeventsource ("ABC", "Custom Event ");
// Write event
EventLog. writeentry ("ABC", "Hello world! ", Eventlogentrytype. Warning );


From: http://www.mzwu.com/article.asp? Id = 2014
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.