记录错误日志
using System.Diagnostics;
protected void Application_Error(Object sender, EventArgs e)
{
string errMsg = "<link rel=\"stylesheet\" href=\"/ThePhile/Styles/ThePhile.CSS\">";
errMsg += "<h1>Application Error</h1><hr/>An unexpected error has occurred in this Application. The system " +
"administrators have been notified. Please feel free to contact us with the information " +
"surrounding this error.<br/>"+
"The error occurred in: "+Request.Url.ToString()+"<br/>"+
"Error Message: <font class=\"ErrorMessage\">"+Server.GetLastError().Message.ToString()+"</font><hr/>"+
"<b>Stack Trace:</b><br/>"+
Server.GetLastError().ToString();
Response.Write( errMsg );
if (!EventLog.SourceExists("ThePhile.COM"))
{
EventLog.CreateEventSource("ThePhile.COM", "Application");
}
EventLog.WriteEntry("ThePhile.COM", Server.GetLastError().Message, EventLogEntryType.Error);
Server.ClearError();
}
web.configprotected void Application_Error(Object sender, EventArgs e)
{
string errMsg = "<link rel=\"stylesheet\" href=\"/ThePhile/Styles/ThePhile.CSS\">";
errMsg += "<h1>Application Error</h1><hr/>An unexpected error has occurred in this Application. The system " +
"administrators have been notified. Please feel free to contact us with the information " +
"surrounding this error.<br/>"+
"The error occurred in: "+Request.Url.ToString()+"<br/>"+
"Error Message: <font class=\"ErrorMessage\">"+Server.GetLastError().Message.ToString()+"</font><hr/>"+
"<b>Stack Trace:</b><br/>"+
Server.GetLastError().ToString();
Response.Write( errMsg );
if (!EventLog.SourceExists("ThePhile.COM"))
{
EventLog.CreateEventSource("ThePhile.COM", "Application");
}
EventLog.WriteEntry("ThePhile.COM", Server.GetLastError().Message, EventLogEntryType.Error);
Server.ClearError();
}
<customErrors mode="RemoteOnly" defaultRedirect="error.aspx"/>
posted on 2007-10-22 14:26 jueban's space 阅读(184) 评论(0) 编辑 收藏 举报