0
votes

I am writing an ASP.NET Core 2.0 application in Visual Studio 2017. I have logging in the controllers like so:

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

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

This generates logs in the debug window just fine:

WebApplication4.Controllers.HomeController:Information: In The Index

However, I would like to not log all these telemetry methods:

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}"}}}}

My appsettings.json looks like this:

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

How do I filter out just the telemetry messages?

1

1 Answers

1
votes

In Startup.Configure() add the following line Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.DisableTelemetry = true;.

Sources