Code Snippet posted by:
Abhi2434 | Posted on: 10/2/2010 | Category:
C# Codes | Views: 2560 | Status:
[Member] [Microsoft_MVP] [MVP] |
Points: 40
|
Alert Moderator
Writing to Eventlog is most simple. .NET provides a class which lets you write to EventLog very simply.
public static bool WriteEventLog(string Message)
{
try
{
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.
www.abhisheksur.com