liveBook · Manning

Logging level

As explained in Pro ASP.NET Core 7, Tenth Edition

A logging level value is a named setting that specifies the severity threshold or disabled state for log messages.

A logging level is a named threshold that controls which messages a category emits. Messages below the configured minimum are discarded; None disables messages for that category. section 15.3.3

Choose a level according to the detail and urgency required:

  • Trace records low-level diagnostic detail. section 15.3.1
  • Debug supports development diagnostics and production problem resolution. section 15.3.1
  • Information records the application’s general state. section 15.3.1
  • Warning records unexpected minor problems; Error records unhandled errors; Critical records serious failures. section 15.3.1

ASP.NET Core reads thresholds from the Logging:LogLevel configuration section. A category comes from the logger’s generic type or explicit name: Platform.Population can receive a direct setting, inherit one from Platform, or fall back to Default. section 15.3.3 section 15.2

Development and database diagnostics

A development configuration can set Default to Debug while retaining Information for System and Microsoft. A database-oriented configuration can set Microsoft.EntityFrameworkCore to Information so Entity Framework Core SQL statements appear in the log. section 15.3.3 section 17.5.3

Listing 15.24 Configuring the appsettings.Development.json file in the Platform folder
{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information",
      "Microsoft.AspNetCore": "Warning",
      "Microsoft.AspNetCore.Routing": "Debug"
    }
  }
}

Inspect a category-specific configuration that keeps general ASP.NET Core logging at Warning while enabling Debug output for routing. section 15.3.3

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Explains severity meanings, category matching, configuration inheritance, development overrides, and disabling; stops short of provider internals.
Examples
Uses appsettings files, development overrides, routing diagnostics, population requests, and Entity Framework Core SQL output.
What it assumes
Assumes familiarity with ASP.NET Core logging categories and configuration files while establishing the LogLevel hierarchy from configuration basics.
What you can do after
Configure logging thresholds by category and verify the resulting diagnostic output.
How it connects
Connects logging levels to logging categories, configuration, ASP.NET Core, and Entity Framework Core.

Also explained in

Compare how 9 books explain logging level →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.