Mega Code Archive

 
Categories / C# / Windows
 

Check Event Source Existance and Create Event Source

using System; using System.Diagnostics; class MainClass {     public static void Main() {         if (!EventLog.SourceExists("C#")) {             EventLog.CreateEventSource("C#", "Application");         }         EventLog.WriteEntry(             "C#",                          // Registered event source             "A simple test event.",        // Event entry message             EventLogEntryType.Information, // Event type             1,                             // Application-specific ID             0,                             // Application-specific category             new byte[] { 10, 55, 200 }       // Event data         );     } }