c# - 如何通过代码启用 EnableSqlCommandTextInstrumentation?
问题描述
根据文档,您需要将以下内容添加到applicationInsights.config
文件中以启用完整的 SQL 日志记录:
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
<EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
</Add>
但是在我的 ASP.NET 应用程序中,在 Azure 应用程序服务中托管的 .NET Framework 4.7.2 上运行,我通过代码启用/配置 Application Insights:
TelemetryConfiguration.Active.DisableTelemetry = false;
TelemetryConfiguration.Active.InstrumentationKey = setting.ApplicationInsightsInstrumentationKey;
如何通过代码启用此设置?
PS:Web App中的设置已正确启用。
解决方案
似乎即使通过代码启用 AI,它也会从配置文件中获取设置。
我将它添加到我的applicationInsights.config
,它现在似乎可以工作了。
推荐阅读
- css - 如何使用块显示将thead 和 tbody 宽度保持在 100%
- javascript - 表单提交页面刷新后显示隐藏的 div
- c# - EF core 2.1 使用投影
- c# - 如何将数据从数据表复制到数据库表?
- reactjs - 我如何在反应中运行现有项目
- javascript - 过滤 JSON 数据 ( D3.js )
- android - 领域 - 插入没有重复的条目
- java - 对类的对象进行排序
- javascript - How to close the dropdown if the user clicks outside of it?
- javascript - 当 NVDA 开启时,区分按键并在 Mozilla 中单击