Azure Logs Monitor: console logs level is not correct

David 31 Reputation points
2023-12-08T12:07:28.0133333+00:00

We use basic console logging in JSON single-line format. appsettings.json looks like the following.

"Logging": {
  "LogLevel": {
    "Default": "Information",
    "Microsoft": "Warning",
    "Microsoft.Hosting.Lifetime": "Information"
  },
  "Console": {
    "FormatterName": "json",
    "FormatterOptions": {
      "SingleLine": true,
      "IncludeScopes": true,
      "UseUtcTimestamp": true
    }
  }
}   

Configuration: Microsoft.Extensions.Logging 7.0.0 and we do not have a custom implementation nor third-party solution like NLog.

The issue is that in Azure Logs Monitor, the Level column has the Informational type every time. How is it recognized? Should we change the format of the logged message to be correctly recognized?

Azure Logs Monitor: incorrect log level

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,278 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,567 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,196 Reputation points Microsoft Employee
    2023-12-11T21:25:08.7266667+00:00

    @David

    The level comes from your method used by your ILogger<T> implementation, i.e., _logger.LogInformation or _logger.Log(LogLevel.Information,...), see Logging in .NET Core and ASP.NET Core | Microsoft Learn for more information.

    I'm making assumptions based off what you've provided, but it looks as if you're logging event or object as Information in your code, so I would search for those categories that are shown in ResultDescription and see what sort of (bubble up) logging is taking place.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.