这是与this相同的问题,但对于最新版本的应用程序洞察力2.2.1
自从更新到2.2版本以来,调试输出中填充了AI数据,即使它像以前那样被禁用了。
以前AI是在启动时启用的,我可以这样做:
services.AddApplicationInsightsTelemetry(options =>
{
options.EnableDebugLogger = false;
options.InstrumentationKey = new ConnectionStringGenerator().GetAITelemetryKey();
});根据新的VS模板,添加应用程序洞察的新方法是将其添加到Program.cs中,如下所示:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseApplicationInsights(connectionStringGenerator.GetAITelemetryKey())
.UseSerilog()
.Build();在这种情况下,没有采用任何选项的构造,如果我删除'UseApplicationInsights‘并恢复为原始方法,则没有什么不同。无论哪种方式,我都会得到一个充满AI日志的输出调试窗口。
事实上,即使没有加载AI的方法(例如,我删除了'UseApplicationInsights‘和'AddApplicationInsightsTelemetry’,我也会得到日志。
谢谢你的帮助。
发布于 2018-03-06 14:01:01
Visual Studio将激活Application Insights,即使您没有启用它的代码也是如此。您可以创建环境变量ASPNETCORE_PREVENTHOSTINGSTARTUP = True,以防止Visual Studio点亮Application Insights。该怎么做呢?右键单击VS中的项目,选择Properties.In调试选项添加环境变量,如下面的截图所示。

发布于 2018-03-09 03:45:47
您可以通过将DOTNET_CLI_TELEMETRY_OPTOUT环境变量设置为1来退出遥测(例如,用于调试)。

https://stackoverflow.com/questions/49074220
复制相似问题