By default, ASP.NET records all uncaught exceptions to system Event Log. I’m aware of the fact that one should have a proper logging facility in place, but this is better than nothing and it serves well as a temporary solution.
I would like to be able to filter efficiently the events in the log. I learned that, when logging programmatically, you can set a custom value for the Source column in the event log via:
EventLog eventLog = new EventLog('Application'); eventLog.Source = 'My custom name'; eventLog.WriteEntry('Some error description ...', EventLogEntryType.Error);
However, ASP.NET sets this value to ‘ASP.NET’ followed by its version. I briefly checked the documentation of web.config, but did not find an obvious place to change it. I wonder if it can be changed at all.
Your best bet is to use the source property as intended, but use an installer class in your installer to set up the registry at install time (under Admin), eg.:
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.Diagnostics; namespace InstallerClasses { [RunInstaller(true)] public partial class EventLog : Installer { private EventLogInstaller eventLogInstaller; /// /// Creates the event log for MyApp /// public EventLog() { InitializeComponent(); // Create an instance of an EventLogInstaller. eventLogInstaller = new EventLogInstaller(); // Set the source name of the event log. eventLogInstaller.Source = 'MySource'; // Set the event log that the source writes entries to. eventLogInstaller.Log = 'Application'; // Add myEventLogInstaller to the Installer collection. Installers.Add(eventLogInstaller); } } }And make sure it gets run as a Custom Action in your installer.