EventLog.SourceExists : EventLog « System.Diagnostics « C# / C Sharp by API






EventLog.SourceExists

  


using System;
using System.Diagnostics;

class MainClass
{
    public static void Main () 
    {
        if (!EventLog.SourceExists("MyEventSource")) 
        {
            EventLog.CreateEventSource("MyEventSource", "Application");
        }

        EventLog.WriteEntry(
            "MyEventSource",               
            "A simple test event.",        
            EventLogEntryType.Information, 
            1,                             
            0,                             
            new byte[] {10, 55, 200}       
        );

    }
}

   
    
  








Related examples in the same category

1.new EventLog()
2.EventLog.CreateEventSource
3.EventLog.Delete
4.EventLog.DeleteEventSource
5.EventLog.Entries
6.EventLog.Log
7.EventLog.Source
8.EventLog.WriteEntry