[英]Application Insights Live Metrics with ASP.Net MVC and Web Api
[英]How to log ASP.NET Web API request body into a Application Insights failure?
我使用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);
}
}
有沒有方法可以記錄Web API請求主體,以便我可以在Azure門戶的Application Insights儀表板上查看它?
您可以創建ExceptionTelemetry實例並添加自定義屬性。 然后調用常規的Track方法。
var telemetry = new ExceptionTelemetry(context.Exception);
telemetry.Properties.Add("name", "value");
new TelemetryClient().Track(telemetry);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.