您的位置:首页 > 编程语言 > ASP

我在Asp.net记录错误日志的代码

2009-05-17 13:48 519 查看
看一下还比较实用吧

try

{

System.IO.FileStream fs1 = new System.IO.FileStream(HttpContext.Current.Server.MapPath("../labourdb/logtxt.txt"), System.IO.FileMode.Append);

System.IO.StreamWriter sw1 = new System.IO.StreamWriter(fs1);

sw1.WriteLine("**************************************************");

sw1.WriteLine("日期:" + System.DateTime.Now);

sw1.WriteLine("登入名:" + txt_id.Text);

sw1.WriteLine("密码:" + txt_pwd.Text);//51aspx

sw1.WriteLine("IP:" + Request.ServerVariables["REMOTE_ADDR"].ToString());

sw1.WriteLine("*************************************************");

sw1.Close();

}

catch

{

throw;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: