mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:13:26 +08:00
【优化】调整全局异常处理器及过滤器异常日志存储名称问题,日志记录更加详细直观,同时修改类命名。
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace CoreCms.Net.Middlewares;
|
||||
/// <summary>
|
||||
/// 异常错误统一返回记录
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace CoreCms.Net.Middlewares;
|
||||
/// <summary>
|
||||
/// 异常错误统一返回记录
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace CoreCms.Net.Middlewares
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseExceptionHandlerMiddForAdmin(this IApplicationBuilder app)
|
||||
{
|
||||
return app.UseMiddleware<ExceptionHandlerMiddForAdmin>();
|
||||
return app.UseMiddleware<ExceptionHandlerMiddlewareForAdmin>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,7 +48,7 @@ namespace CoreCms.Net.Middlewares
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseExceptionHandlerMiddForClent(this IApplicationBuilder app)
|
||||
{
|
||||
return app.UseMiddleware<ExceptionHandlerMiddForClent>();
|
||||
return app.UseMiddleware<ExceptionHandlerMiddlewareForClent>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user