So hey.
I'm working on this project where I'll have three instances of a .NET Forms application and an ASP.NET application reading from and writing to the same database. Since there is a small amount of information in the database, there's a chance that two users will end up modifying the same piece of information. I won't be around to watch it happen, so I need to make sure the exception's message and stack trace are written down. I'm not so sure if this works in ASP.NET, but (according to MSDN documentation) it works in Windows Forms as long as your application is granted 'write' permission. Also, make sure you have referenced System.dll and you are using System.Diagnostics.
Happy error logging.
1: public static void LogError(Exception ex, EventLog eventLog)
2: {
3: if (!(EventLog.SourceExists("MySource")))
4: {
5: EventLog.CreateEventSource("MySource", "MyLogName");
6: }
7: eventLog.Source = "MySource";
8: eventLog.WriteEntry(ex.Message + " " + ex.StackTrace, System.Diagnostics.EventLogEntryType.Error);
9: }