public class ErrorAttribute : HandleErrorAttribute { public override void OnException(ExceptionContext filterContext) { base.OnException(filterContext); string path = filterContext.HttpContext.Server.MapPath("~/Exception.txt"); using (StreamWriter sw = System.IO.File.AppendText(path)) { sw.WriteLine(DateTime.Now.ToString() + ":" + filterContext.Exception.Message); } } }