阻止 Application Insights 发布到调试控制台

Posted

技术标签:

【中文标题】阻止 Application Insights 发布到调试控制台【英文标题】:Stop Application Insights from posting to Debug console 【发布时间】:2015-04-23 10:44:19 【问题描述】:

现在我真的很喜欢 Visual Studio 2013 的新 Application Insights,我不想删除它。但是,它确实向我的 Debug 输出发送了大量垃圾邮件。

我得到像

这样的输出行
Application Insights Telemetry: "ver":1,"name":"Microsoft.ApplicationInsights.PerformanceCounter","time":"2015-04-23T11:38:03.1252550+01:00","iKey":"758c18d5-055e-48a8-bbcf-9c3301402b2c","tags":"ai.internal.sdkVersion":"0.13.2.132","ai.application.ver":"Unknown","ai.device.type":"PC","ai.device.id":"Pat-PC","ai.device.oemName":"Dell Inc.","ai.device.model":"Dell XPS430                  ","ai.device.network":"6","ai.device.language":"en-GB","ai.device.machineName":"Pat-PC","ai.device.os":"Windows NT 6.1.7601.65536","data":"type":"Microsoft.ApplicationInsights.PerformanceCounterData","item":"categoryName":"Processor","counterName":"% Processor Time","instanceName":"_Total","value":35.9710731506348,"ver":1

这有点让我无法将调试输出实际用于我的调试语句。如何使 Application Insights 静音,或将 Visual Studio 配置为不显示这些语句?

【问题讨论】:

反编译 .NET 程序集让生活变得轻松,它很快帮我找到了this web page。将其设置为 false 是的!这绝对成功了,谢谢! Disable application insights in debug的可能重复 【参考方案1】:

简单地关闭这些消息,没有其他副作用:

TelemetryDebugWriter.IsTracingDisabled = true;

【讨论】:

一个副作用是 Visual Studio 中的“应用程序洞察”窗格不会收到输出【参考方案2】:

汉斯·帕桑特是对的。 DeveloperMode 是触发 AI 在 DebugOutput 中写入事件的原因。请注意,它还强制 AI 立即发送数据。因此,如果我们将其设置为 false,数据将被批处理并每分钟发送一次。

【讨论】:

我们如何禁用消息但保留数据的自动刷新? @MarkSowul 看起来您可以使用 TelemetryDebugWriter.IsTracingDisabled = true 仅关闭调试输出。

以上是关于阻止 Application Insights 发布到调试控制台的主要内容,如果未能解决你的问题,请参考以下文章

API Application Insights 使用的良好实践

Application Insights 数据采样

ILogger 到 Application Insights

Application Insights URL 分组

Azure Application Insights 不显示数据

更改 Application Insights 的位置?