public static void Log(Exception ex) { vmErrorStack objError = new vmErrorStack(); StackTrace st = new StackTrace(true); StackFrame sf = st.GetFrame(1); objError.ErrorMethod = sf.GetMethod().ToString(); objError.ErrorFile = sf.GetFileName().ToString(); objError.ErrorLine = sf.GetFileLineNumber().ToString(); objError.ErrorDate = DateTime.Now.ToString(); objError.ErrorPath = HttpContext.Current.Request.Url.AbsolutePath; objError.ErrorType = ex.GetType().ToString(); objError.ErrorMessage = ex.Message; objError.ErrorSource = ex.Source; objError.ErrorStack = ex.StackTrace; //objErrorLog.SaveErrorLog(objError); }
/// <summary> /// Save Data To Database /// <para>Use it when save data through a stored procedure</para> /// </summary> public int SaveErrorLog(vmErrorStack model) { int result = 0; try { Hashtable ht = new Hashtable(); ht.Add("tblErrorLog", model); string spQuery = "[Set_AppErrorLog]"; result = GenericFactoryFor_Error.ExecuteCommand(spQuery, ht); } catch (Exception ex) { result = 0; ErrorLog.Log(ex); ex.ToString(); } return(result); }