'Core app logging requests but not traces to app insights
I noticed that my .net core app is logging requests, but not traces to my azure app insights.
I'm setting up app insights in my Startup.cs
services.AddApplicationInsightsTelemetry(options =>
{
options.InstrumentationKey = Configuration["ApplicationInsightsInstrumentationKey"];
});
I'm injecting ILogger in my controller like such
private readonly ILogger<HealthCheckController> _logger;
public HealthCheckController(ILogger<HealthCheckController> logger)
{
_logger = logger;
}
[HttpGet]
public IActionResult HealthCheck()
{
// Custom EventId for logging
var eventId = EventDefinition.TestMicroservice.HealthCheckController.HealthCheck;
_logger.LogInformation(eventId, "Test Microservice health check successful.");
return Ok("Test Microservice is running!");
}
Am I missing something? I've hit my controller multiple times and I'm seeing requests getting logged, but my custom log messages are nowhere to be found under traces.
Solution 1:[1]
By default, only Warning or higher is collected by ApplicationInsights. You can change it following the doc here: https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#how-do-i-customize-ilogger-logs-collection
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | cijothomas |