我想在Catch {}中放置一個方法,將錯誤發送到我的「.log」文件。 我喜歡把頁面的地址和發生錯誤的方法。所以我希望你能幫助我,告訴我如何定義「strErrorPath」並將其作爲我的方法輸入。找到在C#頁面發生錯誤的地方的路徑
public static void SendErrorToPersonalErrorMessage(Exception ex,string strErrorPath)
{
string strErrorMEssage = string.Format("Error:{0} Time:{1:yyy/mm/dd - hh:mm:ss},Address:{2}", ex.Message, System.DateTime.Now, strErrorPath);
System.IO.StreamWriter oStreamWriter = null;
string strPersonalErrorMEssagePath = "~/App_Data/Log/PersonalErrorMessage.log";
string strPersonalErrorMessagePathName = HttpContext.Current.Server.MapPath(strPersonalErrorMEssagePath);
oStreamWriter = new System.IO.StreamWriter(strPersonalErrorMessagePathName, true, System.Text.Encoding.UTF8);
}`enter code here`
你在靶向:的WinForms,WPF,ASP ..? __Always__正確標記您的問題! – TaW
我希望能找出在命名空間的c#類中會發生的那些錯誤:ASP.NET Web Form的工具。這很重要嗎? – Keyvan