我正在尝试在Azure中使用应用程序洞察。我做的每件事都像例子一样。然而,当我试图打电话给
app.UseApplicationInsightsRequestTelemetry()在配置中,我的web应用程序停止工作。我尝试使用构造函数手动创建TelemetryClient,但是
_telemetryClient.TrackException(ex);什么都不做。
在我看来注射有问题。我把Autofac逗乐了然后试着注射
_telemetryClient = app.ApplicationServices.GetService<TelemetryClient>();但这也无济于事。
有什么想法有什么不对吗?
发布于 2016-04-12 12:33:07
正确的答案是我们需要得到正确的TelemetryClient对象。不知道为什么没有这方面的文档,但应该如下所示:
app.UseExceptionHandler(errorApp =>
{
var telemetry = ServiceProviderExtensions.GetService<TelemetryClient>(errorApp.ApplicationServices);
}https://stackoverflow.com/questions/33609940
复制相似问题