Friday, October 8, 2010

Write to Event Viewer

/// <summary>
/// Method to write Errors to Event viewer
/// </summary>
/// <param name="message">message</param>
static void WriteToEventViewer(string message)
{
string sSource = "Sample";
string sLog = "MyApplication";

if (!EventLog.SourceExists(sSource))
{
EventLog.CreateEventSource(sSource, sLog);
}
EventLog.WriteEntry(sSource, message,

EventLogEntryType.Error);
}

for more information refer this
http://msdn.microsoft.com/en-us/library/xzwc042w.aspx

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete