diff --git a/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs b/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs index f992cf59..e3dfee57 100644 --- a/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs +++ b/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs @@ -36,7 +36,7 @@ namespace CoreCms.Net.Filter public void OnException(ExceptionContext context) { - NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", "全局捕获异常", context.Exception); + NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", context.Exception.Message, context.Exception); HttpStatusCode status = HttpStatusCode.InternalServerError; diff --git a/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs b/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs index 0ff643a0..0c4e2a13 100644 --- a/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs +++ b/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs @@ -36,7 +36,7 @@ namespace CoreCms.Net.Filter public void OnException(ExceptionContext context) { - NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", "全局捕获异常", context.Exception); + NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", context.Exception.Message, context.Exception); HttpStatusCode status = HttpStatusCode.InternalServerError; diff --git a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForAdmin.cs b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForAdmin.cs similarity index 92% rename from CoreCms.Net.Middlewares/ExceptionHandlerMiddForAdmin.cs rename to CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForAdmin.cs index 77a7046e..06b0977d 100644 --- a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForAdmin.cs +++ b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForAdmin.cs @@ -26,11 +26,11 @@ namespace CoreCms.Net.Middlewares; /// /// 异常错误统一返回记录 /// -public class ExceptionHandlerMiddForAdmin +public class ExceptionHandlerMiddlewareForAdmin { private readonly RequestDelegate _next; - public ExceptionHandlerMiddForAdmin(RequestDelegate next) + public ExceptionHandlerMiddlewareForAdmin(RequestDelegate next) { _next = next; } @@ -50,7 +50,7 @@ public class ExceptionHandlerMiddForAdmin private async Task HandleExceptionAsync(HttpContext context, Exception ex) { if (ex == null) return; - NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex)); + NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "全局捕获异常", ex.Message, ex); await WriteExceptionAsync(context, ex).ConfigureAwait(false); } diff --git a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForClent.cs b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForClent.cs similarity index 92% rename from CoreCms.Net.Middlewares/ExceptionHandlerMiddForClent.cs rename to CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForClent.cs index 6acf793d..b5d5219a 100644 --- a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForClent.cs +++ b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForClent.cs @@ -26,12 +26,12 @@ namespace CoreCms.Net.Middlewares; /// /// 异常错误统一返回记录 /// -public class ExceptionHandlerMiddForClent +public class ExceptionHandlerMiddlewareForClent { private readonly RequestDelegate _next; - public ExceptionHandlerMiddForClent(RequestDelegate next) + public ExceptionHandlerMiddlewareForClent(RequestDelegate next) { _next = next; } @@ -52,7 +52,7 @@ public class ExceptionHandlerMiddForClent { if (ex == null) return; - NLogUtil.WriteAll(LogLevel.Error, LogType.ApiRequest, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex)); + NLogUtil.WriteAll(LogLevel.Error, LogType.ApiRequest, "全局捕获异常", ex.Message, ex); await WriteExceptionAsync(context, ex).ConfigureAwait(false); } diff --git a/CoreCms.Net.Middlewares/MiddlewareHelpers.cs b/CoreCms.Net.Middlewares/MiddlewareHelpers.cs index 76eda593..1786f00e 100644 --- a/CoreCms.Net.Middlewares/MiddlewareHelpers.cs +++ b/CoreCms.Net.Middlewares/MiddlewareHelpers.cs @@ -38,7 +38,7 @@ namespace CoreCms.Net.Middlewares /// public static IApplicationBuilder UseExceptionHandlerMiddForAdmin(this IApplicationBuilder app) { - return app.UseMiddleware(); + return app.UseMiddleware(); } /// @@ -48,7 +48,7 @@ namespace CoreCms.Net.Middlewares /// public static IApplicationBuilder UseExceptionHandlerMiddForClent(this IApplicationBuilder app) { - return app.UseMiddleware(); + return app.UseMiddleware(); } ///