不记录遥测信息以使用 ASP.Net Core 2.0 应用调试 window

Not logging telemetry info to debug window with ASP.Net Core 2.0 app

我正在 Visual Studio 2017 年编写一个 ASP.NET Core 2.0 应用程序。我已经像这样登录控制器:

    public HomeController(ILogger<HomeController> logger)
    {
        this._logger = logger;
    }

    public IActionResult Index()
    {
        _logger.LogInformation("In The Index");
        return View();
    }

这会在调试中生成日志 window 很好:

WebApplication4.Controllers.HomeController:Information: In The Index

但是,我想记录所有这些遥测方法:

Application Insights Telemetry (unconfigured): {"name":"Microsoft.ApplicationInsights.Dev.Message","time":"2017-10-09T19:11:31.1311753Z","tags":{"ai.internal.nodeName":"DESKTOP-MBRK754","ai.operation.id":"7a80811a-422cb8019de22af6","ai.location.ip":"127.0.0.1","ai.cloud.roleInstance":"DESKTOP-MBRK754","ai.operation.parentId":"|7a80811a-422cb8019de22af6.","ai.application.ver":"1.0.0.0","ai.operation.name":"GET Home/Index","ai.internal.sdkVersion":"aspnet5c:2.1.1"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"Executing action method WebApplication4.Controllers.HomeController.Index (WebApplication4) with arguments ((null)) - ModelState is Valid","severityLevel":"Information","properties":{"AspNetCoreEnvironment":"Development","ValidationState":"Valid","ActionName":"WebApplication4.Controllers.HomeController.Index (WebApplication4)","CategoryName":"Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker","DeveloperMode":"true","{OriginalFormat}":"Executing action method {ActionName} with arguments ({Arguments}) - ModelState is {ValidationState}"}}}}

我的 appsettings.json 看起来像这样:

"Logging": {
  "IncludeScopes": false,
  "LogLevel": {
    "Default": "Information"
  }
}

如何过滤掉 遥测消息?

Startup.Configure() 中添加以下行 Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.DisableTelemetry = true;.