【问题标题】:Not logging telemetry info to debug window with ASP.Net Core 2.0 app不使用 ASP.Net Core 2.0 应用程序将遥测信息记录到调试窗口
【发布时间】:2018-03-21 02:01:52
【问题描述】:

我正在 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();
    }

这在调试窗口中生成日志就好了:

WebApplication4.Controllers.HomeController:信息:在索引中

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

Application Insights 遥测(未配置):{"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":"执行动作方法 WebApplication4.Controllers .HomeController.Index (WebApplication4) 带参数 ((null)) - ModelState 有效","severityLevel":"Information","properties":{"AspNetCoreEnvironment":"Development","ValidationState":"Valid"," ActionName":"WebApplication4.Controllers.HomeController.Index (WebApplication4)","CategoryName":"Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker","DeveloperMode":"true","{OriginalFormat}":"执行动作我thod {ActionName} 带参数 ({Arguments}) - ModelState 是 {ValidationState}"}}}}

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

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

如何过滤遥测消息?

【问题讨论】:

标签: azure-application-insights asp.net-core-2.0 .net-core-2.0


【解决方案1】:

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

Sources

【讨论】:

    猜你喜欢
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    • 2021-02-24
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    相关资源
    最近更新 更多