错误日志类-也可以用于查看输出结构
/// <summary>
??????? /// 寫入錯誤日志
??????? /// </summary>
??????? /// <param name="content">錯誤內(nèi)容</param>
??????? public static void WriteLog(string content)
??????? {
??????????? string strFilePath = HttpContext.Current.Server.MapPath("~/") + "ErrorLog.html";
??????????? string strUserIp = HttpContext.Current.Request.UserHostAddress;
??????????? if (!File.Exists(strFilePath))
??????????? {
??????????????? FileStream fStream = new FileStream(strFilePath, FileMode.CreateNew);
??????????????? fStream.Flush();
??????????????? fStream.Close();
??????????????? fStream = null;
??????????? }
??????????? StreamWriter sWriter = new StreamWriter(strFilePath, true, System.Text.Encoding.UTF8);
??????????? string textWrite = "Time : " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "? UserIp :" + strUserIp + " <br/>Error : " + content + "<br/><br/>★★★★★★★★★★★★★★★★★★★★★★★★★★★★<br/><br/>";
??????????? sWriter.WriteLine(textWrite);
??????????? sWriter.Flush();
??????????? sWriter.Close();
??????????? sWriter = null;
??????? }
轉(zhuǎn)載于:https://www.cnblogs.com/qizhinan/p/3360883.html
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的错误日志类-也可以用于查看输出结构的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 复旦突然减招!顶流211连甩三张“复活牌
- 下一篇: 一听就会,一做就废,该如何破局?