【问题标题】:How to enable EnableSqlCommandTextInstrumentation via code?如何通过代码启用 EnableSqlCommandTextInstrumentation?
【发布时间】:2021-09-27 06:58:51
【问题描述】:

根据the documentation,您需要将以下内容添加到您的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;

如何通过代码启用此设置?

P.S.:Web App 中的设置已正确启用。

【问题讨论】:

    标签: c# sql asp.net azure azure-application-insights


    【解决方案1】:

    似乎即使通过代码启用 AI,它也会从配置文件中获取设置。
    我将它添加到我的applicationInsights.config,现在它似乎可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2012-05-13
      • 2020-11-10
      • 2021-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多