Mega Code Archive

 
Categories / ASP.Net Tutorial / ASP Net Instroduction
 

Log exception in Global asax (C#)

using System; using System.Collections; using System.ComponentModel; using System.Web; using System.Web.SessionState; namespace MyApp {   public class Global : System.Web.HttpApplication   {     protected void Application_Error(Object sender, EventArgs e)     {       System.Diagnostics.EventLog myEventLog;       Exception ex=Server.GetLastError();       myEventLog=new System.Diagnostics.EventLog();       myEventLog.Log="Application";       myEventLog.Source="Default";       myEventLog.WriteEntry(ex.ToString());       myEventLog=null;     }   } }