Tuesday, March 27, 2007

Adding Errors to Event Log

using System.Diagnostics;

private void AddLog(string sErrSource, string sErrMessage, EventLogEntryType ErrType)
{
EventLog objLog = new EventLog("AppLog");
objLog.Source=sErrSource;
objLog.WriteEntry(sErrMessage,ErrType);
}
This function will create an event log called "AppLog" and adds the source and message into that.
EventLogEntryType enum contains
1. Error
2. FailureAudit
3. Information
4. SuccessAudit
5. Warning

No comments: