首页 文章

在控制台应用程序上设置应用程序洞察

提问于
浏览
0

我已经在控制台应用程序上运行Log4Net,并希望将日志事件发送到Application Insights .

我无法通过右键单击我的项目来添加AI - 它不会显示为选项 .

我已经通过NuGet安装了AI SDK,并且能够创建遥测客户端,但不知道在哪里添加检测密钥 .

This教程说:

在代码中设置检测密钥:

TelemetryConfiguration.Active.InstrumentationKey = " your key ";

或者在ApplicationInsights.config中(如果您安装了一个标准的遥测包):

<InstrumentationKey>your key</InstrumentationKey>

我没有ApplicationInsights.config文件,因为我无法将AI添加到项目中 . 如果我在实例化遥测客户端时添加密钥会这样吗?

var telemetryClient = new TelemetryClient { InstrumentationKey = ConfigurationManager.AppSettings["applicationInsights"] };

1 回答

  • 1

    你最后的建议可能会奏效 . 你也可以这样做:

    TelemetryConfiguration.Active.InstrumentationKey =  ConfigurationManager.AppSettings["applicationInsights"];
    

相关问题