Write To Application Event Log Using C#

Sample Code:


using System;
using System.Diagnostics;

namespace AppEventLog
{
public class AppEventLog
{
public static void Write(string message)
{
if (!System.Diagnostics.EventLog.SourceExists("MyApp"))
{
System.Diagnostics.EventLog.CreateEventSource("MyApp", "Application");
}

System.Diagnostics.EventLog.WriteEntry("MyApp", message);
}
}
}