为什么 Application Insights TrackException 没有记录任何内容?

问题描述 投票:0回答:1

我目前正在尝试在 Application Insights 中记录异常以供以后调查。 但是,我尝试使用 TrackException 方法记录的任何异常都不会出现在 Application Insights 中。

Application Insights 事件过滤的docs声明如下:

Exception - 服务器中未捕获的异常,以及您使用 TrackException() 记录的异常。

我正在使用以下代码记录我的异常:

private static readonly TelemetryClient Client = new TelemetryClient{InstrumentationKey = ApplicationInsightsSettings.InstrumentationKey};

public static void TrackException(Exception exception, string traceReference)
{
    var properties = new Dictionary<string, string> {{"Trace Reference", traceReference}};

    Client.TrackException(exception);
    Client.TrackException(exception, properties);
    Client.TrackEvent(traceReference);
}

Whenever I run this code only an event is logged but none of the exceptions are.

c# azure azure-application-insights
1个回答
0
投票

我在 UiPath 中这样做,所以要求可能有点不同, 但是在发送异常时我不得不针对遥测客户端添加一个 Flush

telemetryClient.TrackException(in_exception);
telemetryClient.Flush();
System.Threading.Thread.Sleep(50);
© www.soinside.com 2019 - 2024. All rights reserved.