首页 新闻 会员 周边

ASP.NET Core 中处理所有未处理异常的 middleware 是哪个

0
悬赏园豆:30 [已解决问题] 解决于 2019-02-18 13:03

请问 ASP.NET Core 中处理所有未处理异常的 middleware 是哪个?想找到这个 middleware 知道异常是如果被写入错误日志的

dudu的主页 dudu | 高人七级 | 园豆:30994
提问于:2019-02-18 12:09
< >
分享
最佳答案
0

找到了,是 ExceptionHandlerMiddleware

写错误日志的代码:

_logger.UnhandledException(ex);

DiagnosticsLoggerExtensions 中对应的实现代码

private static readonly Action<ILogger, Exception> _unhandledException =
            LoggerMessage.Define(LogLevel.Error, new EventId(1, "UnhandledException"), "An unhandled exception has occurred while executing the request.");

public static void UnhandledException(this ILogger logger, Exception exception)
{
    _unhandledException(logger, exception);
}
dudu | 高人七级 |园豆:30994 | 2019-02-18 12:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册