EventSource and EventLog.WriteEntry

It's pretty easy to write an entry into Windows event log in ASP.NET

For example, EventLog.WriteEntry("AppName", YourMessage, EventLogEntryType.Error)

However, if you don't have sufficient rights and create the event source in advance

For example, 

if (! EventLog.SourceExists("AppName"))
      EventLog.CreateEventSource("AppName", "AppName");

Alternatively, you can create the event source manually via RegEdit by adding a new key at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application

No Comments