现在的位置: 首页 > 综合 > 正文

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

2012年10月19日 ⁄ 综合 ⁄ 共 595字 ⁄ 字号 评论关闭
看一下还比较实用吧

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;
    }

抱歉!评论已关闭.