Writing to EventLog
Before using EventLog.WriteEntry
for adding events to event log you should consider calling EventLog.CreateEventSource
to make your application a valid source of events. Keep in mind though that you need administrative privileges for it to succeed, therefore it is best to call it at installation time. So, if you want to write to the application event log by calling:
EventLog.WriteEntry("MyApplicationName", "My event text");
don't forget doing this first:
if (!EventLog.SourceExists("MyApplicationName"))
EventLog.CreateEventSource("MyApplicationName", "Application");