liveBook · Manning

Log filtering

As explained in ASP.NET Core in Action, 3e

A logging filter is a configuration rule that selects log messages for output according to criteria such as severity and namespace.

Log filtering selects messages for output by minimum severity, logger category or namespace, and provider. It reduces noisy output while preserving messages useful for diagnosing failures. section 26.4 section 26.2.1

A filtering setup can combine rules such as:

  • Information or higher by default. section 26.4
  • Warning or higher for categories beginning with Microsoft, reducing framework noise. section 26.4
  • Error or higher for the console provider, while another provider may retain lower levels. section 26.4
  • One most-specific rule per provider and message; applicable rules are not combined. section 26.4

Separate application and framework output

Configure appsettings.json with a Debug default, Warning for Microsoft categories, Information for file logging, and Debug for console logging while retaining the Microsoft Warning override. An Information message from a Microsoft category is therefore omitted by the console provider but can be written by the file provider. section 26.4

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains severity, category, provider, specificity, and layered configuration, but stops short of provider implementation internals.
Examples
Uses ILogger messages, Microsoft namespace filters, console and file providers, appsettings.json, and AddConfiguration().
What it assumes
Assumes familiarity with ILogger, log levels, WebApplicationBuilder, and configuration sections.
What you can do after
Configure ASP.NET Core logging with category- and provider-specific minimum levels through appsettings.json or AddConfiguration().
How it connects
Connects log levels with logging providers, logger categories, namespaces, configuration, and ASP.NET Core.

Also explained in

Compare how 2 books explain log filtering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.