\.NET 6: Ensuring Scoped Log Levels Apply to All Logging Providers
0 reputation · 03 Apr 2022, 20:07 UTC
In .NET 6, developers often use ILogger.BeginScope to set a minimum log level for a block of code, hoping to suppress noisy alerts. However, some logging providers do not honor these scoped levels automatically, leading to inconsistent noise suppression across the application.
The goal is to reduce notification noise by applying scoped log levels uniformly, while still allowing critical alerts to surface. The constraints include provider compatibility, the need to register DiagnosticSource listeners early, and the fact that DiagnosticSource.AllListeners is immutable after startup.
Key questions remain:
- How can we guarantee that
BeginScopelog level changes are respected by all logging providers in .NET 6? - Are there provider‑specific configuration options or extensions that enforce scoped levels across the stack?
- What is the recommended strategy to suppress low‑priority alerts with
DiagnosticSourceandILoggerwithout missing critical events?