Write the Event Log Entry type as Information : Event Log : Windows C# Source Code


Custom Search

C# Source Code » Windows » Event Log »

 

Write the Event Log Entry type as Information








    


 


using System;
using System.Diagnostics;

class MainClass {
    public static void Main() {
        string source = "EventSource";
        string log = "MainClass.LOG";

        EventLog el = new EventLog();

        if (!EventLog.SourceExists(source)) {
            EventLog.CreateEventSource(source, log);
        }
        el.Source = source;

        String message = "Starting Up";
        el.WriteEntry(message, EventLogEntryType.Information);
        message = "Processing";
        el.WriteEntry(message, EventLogEntryType.Information);
        message = "Shutting down";
        el.WriteEntry(message, EventLogEntryType.Information);

        el = new EventLog();

        if (!EventLog.SourceExists(source)) {
            Console.WriteLine("Event Log does not exist!");
            return;
        }
        el.Source = source;

        foreach (EventLogEntry entry in el.Entries) {
            Console.WriteLine("\tEntry: " + entry.Message);
        }
        EventLog.Delete(log);
    }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Windows
» Event Log