[英]How to log ASP.NET Web API request body into a Application Insights failure?
I'm logging my unhandled exceptions in an ExceptionLogger using the TelemetryClient to Application Insights on Azure. 我使用TelemetryClient将未处理的异常记录在ExceptionLogger中,以记录到Azure上的Application Insights。
public class GlobalExceptionLogger : ExceptionLogger
{
public override void Log(ExceptionLoggerContext context)
{
if (context != null && context.Exception != null)
{
//For simplification a new TelemetryClient instance
//This is not recommended!
new TelemetryClient().TrackException(context.Exception);
}
base.Log(context);
}
}
Is there a way to log the Web API Request body so I can view it on the Application Insights dashboard on the Azure Portal? 有没有方法可以记录Web API请求主体,以便我可以在Azure门户的Application Insights仪表板上查看它?
You can create ExceptionTelemetry instance and add custom properties. 您可以创建ExceptionTelemetry实例并添加自定义属性。 Then call general Track method. 然后调用常规的Track方法。
var telemetry = new ExceptionTelemetry(context.Exception);
telemetry.Properties.Add("name", "value");
new TelemetryClient().Track(telemetry);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.