我从来都不废话 能用代码解决的 绝不说废话 (<_>)
void Application_Error(object sender, EventArgs e)
{
// 在出现未处理的错误时运行的代码
//在出现未处理的错误时运行的代码 周祥
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操作系统:" + Request.Browser.Platform.ToString());
str.Append("\r\n\t访问路径:" + Request.Url.ToString());
str.Append("\r\n\t请求参数:" + Server.UrlDecode(Request.Form.ToString()));
str.Append("\r\n.错误信息:" + ex.ToString());
Log.ErrorLog(str);
}
log.cs 文件下载 错误会存储在根目录 app_data 里面
Log