/// <summary> /// 写入错误日志 /// </summary> /// <param name="msg">日志信息</param> /// <param name="insertType">写入方法(数据库/记事本)</param> /// <param name="logType">(错误/信息)</param> /// Author : Napoleon /// Created : 2015-06-05 09:47:20 public static void InsertLog4(string msg, LogType logType = LogType.Error, InsertType insertType = InsertType.All) { SystemLog log = new SystemLog(); log.IpAddress = IpFunc.GetIp(); log.OperateTime = DateTime.Now; log.OperateUrl = HttpContext.Current.Request.Url.ToString(); log.UserName = "******"; log.OperateType = "系统错误"; log.OperateContent = msg; log.InsertLog(logType, insertType); }
/// <summary> /// action异常捕获 /// </summary> /// <param name="filterContext">有关当前请求和操作的信息。</param> /// Author : Napoleon /// Created : 2015-06-05 11:10:24 protected override void OnException(ExceptionContext filterContext) { filterContext.ExceptionHandled = true;//已经处理异常 SystemLog log = new SystemLog(); log.IpAddress = IpFunc.GetIp(); log.OperateTime = DateTime.Now; log.OperateUrl = System.Web.HttpContext.Current.Request.Url.ToString(); log.UserName = "******"; log.OperateType = "DAL层错误"; log.OperateContent = filterContext.Exception.Message; log.InsertLog(LogType.Error, InsertType.All); //页面跳转 filterContext.Result = RedirectToRoute("Default", new { Controller = "Error", Action = "Index" }); base.OnException(filterContext); }