using System; using Library; using Microsoft.AspNetCore.Mvc.Filters; namespace MySystem { public class GlobalExceptions : IExceptionFilter { public void OnException(ExceptionContext context) { string Message = context.Exception.Message; string StackTrace = context.Exception.StackTrace; LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\r\n" + Message + "\r\n" + StackTrace, "Global全局异常处理日志"); } } }