抛出包装的异常未正确记录(在函数调用日志或appinsights中) [英] Throwing a wrapped exception is not logged correctly (in functions invocation log or appinsights)

查看:114
本文介绍了抛出包装的异常未正确记录(在函数调用日志或appinsights中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi,

在我们的函数应用程序中,我们捕获任何抛出的异常,并抛出一个新的附加信息,这有助于我们诊断问题。这用于在监视器日志和appinsights中工作,但是我们
现在只能看到记录的innerexception。

In our functions app we catch any thrown exceptions and throw a new one with additional info which helps us diagnose the issue. This use to work in both the monitor log and appinsights, however we now only see the innerexception logged.

所以这个函数可以做到这一点:

So a function that does this:

try
{
    throw new Exception("inner");
}
catch (Exception exception)
{
  throw new Exception("outer", exception);
}


在监视器日志中生成此内容:

正如您所见,没有提到外部异常消息。这使得诊断生产问题变得非常困难。

As you can see no mention of the outer exception message. This makes diagnosing production issues very difficult.

函数运行时:2.0.12342.0(~2)< br style ="">
地区:UKSouth

Functions runtime: 2.0.12342.0 (~2)
Region: UKSouth

感谢您的帮助

推荐答案

要在Application Insights中记录错误,您可以按如下所示编写它:

To Log the Error in Application Insights you can write it as shown below:

try
{
   throw new Exception("inner");
}
catch(Exception exception)
{
   log.LogError("outer" + exception);
}

监控日志:




这篇关于抛出包装的异常未正确记录(在函数调用日志或appinsights中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆