好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁(yè) > 知識(shí)庫(kù) > Global.asax的Application_Error實(shí)現(xiàn)錯(cuò)誤記錄/錯(cuò)誤日志的代碼

Global.asax的Application_Error實(shí)現(xiàn)錯(cuò)誤記錄/錯(cuò)誤日志的代碼

熱門標(biāo)簽:巫師3為什么地圖標(biāo)注的財(cái)寶沒有 世紀(jì)佳緣地圖標(biāo)注怎么去掉 十堰正規(guī)電銷機(jī)器人系統(tǒng) 寧波自動(dòng)外呼系統(tǒng)代理 辦理400電話證件 手機(jī)地圖標(biāo)注如何刪除 怎么給超市做地圖標(biāo)注入駐店 外呼系統(tǒng)費(fèi)用一年 外呼系統(tǒng)代理品牌
利用Global.asax的Application_Error實(shí)現(xiàn)錯(cuò)誤記錄

錯(cuò)誤日志
復(fù)制代碼 代碼如下:

void Application_Error(object sender, EventArgs e)
{
// 在出現(xiàn)未處理的錯(cuò)誤時(shí)運(yùn)行的代碼
Exception ex = Server.GetLastError().GetBaseException();
StringBuilder str = new StringBuilder();
str.Append("\r\n" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss"));
str.Append("\r\n.客戶信息:");


string ip = "";
if (Request.ServerVariables.Get("HTTP_X_FORWARDED_FOR") != null)
{
ip = Request.ServerVariables.Get("HTTP_X_FORWARDED_FOR").ToString().Trim();
}
else
{
ip = Request.ServerVariables.Get("Remote_Addr").ToString().Trim();
}
str.Append("\r\n\tIp:" + ip);
str.Append("\r\n\t瀏覽器:" + Request.Browser.Browser.ToString());
str.Append("\r\n\t瀏覽器版本:" + Request.Browser.MajorVersion.ToString());
str.Append("\r\n\t操作系統(tǒng):" + Request.Browser.Platform.ToString());
str.Append("\r\n.錯(cuò)誤信息:");
str.Append("\r\n\t頁(yè)面:" + Request.Url.ToString());
str.Append("\r\n\t錯(cuò)誤信息:" + ex.Message);
str.Append("\r\n\t錯(cuò)誤源:" + ex.Source);
str.Append("\r\n\t異常方法:" + ex.TargetSite);
str.Append("\r\n\t堆棧信息:" + ex.StackTrace);
str.Append("\r\n--------------------------------------------------------------------------------------------------");
//創(chuàng)建路徑
string upLoadPath = Server.MapPath("~/log/");
if (!System.IO.Directory.Exists(upLoadPath))
{
System.IO.Directory.CreateDirectory(upLoadPath);
}
//創(chuàng)建文件 寫入錯(cuò)誤
System.IO.File.AppendAllText(upLoadPath + DateTime.Now.ToString("yyyy.MM.dd") + ".log", str.ToString(), System.Text.Encoding.UTF8);
//處理完及時(shí)清理異常
Server.ClearError();
//跳轉(zhuǎn)至出錯(cuò)頁(yè)面
Response.Redirect("~/error.html");
}
您可能感興趣的文章:
  • asp.net 在global中攔截404錯(cuò)誤的實(shí)現(xiàn)方法
  • Global.cs中自動(dòng)獲取未處理的異常
  • 在Global.asax文件里實(shí)現(xiàn)通用防SQL注入漏洞程序(適應(yīng)于post/get請(qǐng)求)
  • Global.asax取絕對(duì)路徑的方法
  • Global.asax取物理路徑/取絕對(duì)路徑具體方法
  • Global.asax的Application_BeginRequest實(shí)現(xiàn)url重寫無(wú)后綴的代碼
  • c#定時(shí)器和global實(shí)現(xiàn)自動(dòng)job示例
  • ASP.net全局程序文件Global.asax用法分析
  • ASP.NET中Global和URLReWrite用法
  • 在C#中g(shù)lobal關(guān)鍵字的作用及其用法

標(biāo)簽:山西 嘉興 通遼 牡丹江 天門 泰州 景德鎮(zhèn)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Global.asax的Application_Error實(shí)現(xiàn)錯(cuò)誤記錄/錯(cuò)誤日志的代碼》,本文關(guān)鍵詞  Global.asax,的,Application,Error,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Global.asax的Application_Error實(shí)現(xiàn)錯(cuò)誤記錄/錯(cuò)誤日志的代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于Global.asax的Application_Error實(shí)現(xiàn)錯(cuò)誤記錄/錯(cuò)誤日志的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章