close

英文口譯

在網路上看到用來記載Exception訊息的方式,看來還蠻不錯用的,記下來以後需要時可使用

有三種貯存方式
1.紀錄在事務檢視器
2.記錄在文字檔
3.用Email寄出訊息

設定方式以下:
先打開Global.asax

  1. "C#" %>   
  2.   
  3. >   
  4.   
  5.     void Application_Start(object sender翻譯社 EventArgs e)   
  6.     {   
  7.         // 利用程式啟動時執行的程式碼   
  8.   
  9.     }   
  10.   
  11.     void Application_End(object sender, EventArgs e)   
  12.     {   
  13.         //  利用程式關閉時履行的程式碼   
  14.   
  15.     }   
  16.   
  17.     void Application_Error(object sender, EventArgs e)   
  18.     {   
  19.         string Message = "";   
  20.         Exception ex = Server.GetLastError();   
  21.         Message = "産生錯誤的網頁:{0}錯誤訊息:{1}堆疊內容:{2}";   
  22.         Message = String.Format(Message翻譯社 Request.Path + Environment.NewLine, ex.GetBaseException().Message + Environment.NewLine, Environment.NewLine + ex.StackTrace);   
  23.   
  24.         //寫入事宜撿視器翻譯社方式一   
  25.         System.Diagnostics.EventLog.WriteEntry("WebAppError", Message, System.Diagnostics.EventLogEntryType.Error);   
  26.   
  27.         //寫入文字檔翻譯社方法二   
  28.         System.IO.File.AppendAllText(Server.MapPath(string.Format("Log{0}.txt"翻譯社 DateTime.Now.Ticks.ToString())), Message);   
  29.   
  30.         //寄出Email,方式三   
  31.         //此方式請參考System.Net.Mail.MailMessage   
  32.   
  33.         //清除Error   
  34.         Server.ClearError();   
  35.   
  36.         Response.Write("系統錯誤,請聯系系統經管員!!");   
  37.   
  38.     }   
  39.   
  40.     void Session_Start(object sender, EventArgs e)   
  41.     {   
  42.         // 啟動新工作階段時執行的程式碼   
  43.   
  44.     }   
  45.   
  46.     void Session_End(object sender, EventArgs e)   
  47.     {   
  48.         // 工作階段竣事時執行的程式碼翻譯    
  49.         // 留意: 只有在 Web.config 檔將 sessionstate 模式設定為 InProc 時,   
  50.         // 才會激發 Session_End 事件。如果將工作階段模式設定為 StateServer    
  51.         // 或 SQLServer,就不會激發這個事務。   
  52.   
  53.     }   
  54.           
  55.   
    參考文章 http://www.dotblogs.com.tw/puma/archive/2008/08/31/5260.aspx



    文章來自: http://blog.xuite.net/yu928/home/34654976-%E4%BD%BF%E7%94%A8Global.asax%E7%9A%84Application_Error%E4有關各國語文翻譯公證的問題歡迎諮詢華頓翻譯公司02-77260932
arrow
arrow
    文章標籤
    翻譯社
    全站熱搜
    創作者介紹
    創作者 roberto7ed2 的頭像
    roberto7ed2

    roberto7ed2@outlook.com

    roberto7ed2 發表在 痞客邦 留言(0) 人氣()