EventLog class under namespace System. Diagnostics

Source: Internet
Author: User

 

Using system;
Using system. diagnostics;
Using system. Threading;

Class mysample
{

Public static void main ()
{


// Create a log source to check whether the log source already exists

If (! EventLog. sourceexists ("My log source "))
{

// The log source of one time cannot be used immediately after creation.

// The recovery time is required to ensure that the log source has been created when the execution program uses the created log source.
// Run this example again to use the new log source.
EventLog. CreateEventSource ("My logs", "my logs ");
Console. WriteLine ("create event source ");
Console. WriteLine ("exiting, please run the program again to use the log source ");
// The log source has been created. Exit the program to allow it to be registered.

Return;
}

// Create an EventLog instance and allocate the log source.
EventLog myLog = new EventLog ();
MyLog. Source = "my log Source ";

// Write a report to the event log.
MyLog. WriteEntry ("Write Event Log ");

}
}

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.