ASP.NET Quick 'n Dirty Exception Logging*
If you need an easy way to handle logging exceptions in your ASP.NET web application but want to avoid all the complexities of using a logging library and / or setting up all the database "Stuff", here is an easy way to handle it: In web.config: <appSettings> <add key="logExceptions" value="true"/> </appSettings > <system.web> In Global.asax.cs: public class Global : System.Web.HttpApplication { public static bool LogErrors = Convert.ToBoolean(ConfigurationManager.AppSettings["logExceptions"]); //... protected void Application_Error(object sender, EventArgs e) { if (LogErrors) { Exception ex = Server.GetLastError().GetBaseException(); File.AppendAllText(Server.MapPath("App_Data/exceptions.txt"), ...