Write to Event Log

Posted by Abhi2434 under C# category on | Points: 40 | Views : 4388
Writing to Eventlog is most simple. .NET provides a class which lets you write to EventLog very simply.

        public static bool WriteEventLog(string Message)
string sSource = "My Custom Application";
string sLog = "Application";
string sEvent = Message;

if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource, sLog);

EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Error, 234);
return true;
catch { return false; }

You can call the method to put a Message on Application EvnetLogger of your system.

Comments or Responses

Login to post response