Log4net 在控制台应用程序上设置应用程序细节

Log4net 在控制台应用程序上设置应用程序细节,log4net,azure-application-insights,Log4net,Azure Application Insights,我已经在控制台应用程序上运行了Log4Net,希望日志事件转到Application Insights 我无法通过右键单击我的项目来添加AI,因为它不显示为选项 我已经通过NuGet安装了AI SDK,能够创建遥测客户端,但不知道在哪里添加检测密钥 教程说: 在代码中设置检测键: 或在ApplicationInsights.config中(如果您安装了标准遥测软件包之一): 你最后的建议可能会奏效。您也可以这样做: TelemetryConfiguration.Active.Instrument

我已经在控制台应用程序上运行了Log4Net,希望日志事件转到Application Insights

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

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

教程说:

在代码中设置检测键:

或在ApplicationInsights.config中(如果您安装了标准遥测软件包之一):


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

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

在你的计划开始的某个地方,主要是。或者在init方法中。
<InstrumentationKey>your key</InstrumentationKey>
var telemetryClient = new TelemetryClient { InstrumentationKey = ConfigurationManager.AppSettings["applicationInsights"] };
TelemetryConfiguration.Active.InstrumentationKey =  ConfigurationManager.AppSettings["applicationInsights"];