public static void ErrorLog(string info) { var path = HttpContext.Current.Server.MapPath("/log/"); DirHelper.CheckFolder(path); FileHelper.WriteFile(path + "log" + DateTime.Now.ToString("yyyyMMddHHmmss") + Character.Random(1000, 9999) + ".txt", "<br/><strong>客户机IP</strong>:" + HttpContext.Current.Request.UserHostAddress + "<br /><strong>错误地址</strong>:" + HttpContext.Current.Request.Url + info); }
/// <summary> /// 指定目录根据异常记录日志 /// </summary> /// <param name="ex"></param> /// <param name="path"></param> public static void Log(Exception ex, string path) { if (path.LastIndexOf("\\") < path.Length) { path += "\\"; } DirHelper.CheckFolder(path); FileHelper.AppendFile(path + "log" + DateTime.Now.ToString("yyyyMMdd") + ".htm", "<strong>客户机IP</strong>:" + HttpContext.Current.Request.UserHostAddress + "<br /><strong>错误地址</strong>:" + HttpContext.Current.Request.Url + ex.Message + Environment.NewLine); }