Torna al Thread

protected void Application_Error(object sender, EventArgs e) { m_mutex.WaitOne(); LogError(); m_mutex.ReleaseMutex(); } protected void LogError() { string strPath = Server.MapPath("/errors/") + "log.log"; FileStream fs = File.Open(strPath, FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); Exception ex = Server.GetLastError(); sw.WriteLine(DateTime.Now.ToString() + ": " + ex.Message + " - Error Message: " + ex.InnerException + " - Stack Trace: " + ex.StackTrace + " - User/Browser: " + Request.Browser.Type + ", " + Request.UserAgent + ", " + Request.UserHostAddress + ", " + Request.UserHostName + ", " + Request.UserLanguages[0] + ", " + Request.Url); sw.Close(); fs.Close(); }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5