Skip to content

fix(logging): Logging:Sentry:LogLevel category entries no longer filter breadcrumbs and events - #5872

Merged
jamescrosswell merged 2 commits into
mainfrom
ai/logging-category-rules-6x-ce9181
Nov 5, 2026
Merged

jamescrosswell merged 2 commits into
mainfrom
ai/logging-category-rules-6x-ce9181

Conversation

@jamescrosswell

@jamescrosswell jamescrosswell commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

6.0.0 (#4700) said the breadcrumb/event logger provider "ignores Logging-Configuration (e.g. via appsettings.json)", and that only the structured-log provider respects it. In practice, a category entry such as Logging:Sentry:LogLevel:Noisy = Error also drops breadcrumbs and events from Noisy.*.

The cause: the event providers and the structured-log providers all carry [ProviderAlias("Sentry")], so Logging:Sentry rules match both. Microsoft.Extensions.Logging prefers the provider-specific rule with the longest matching category. So the category rule beats the category-less AddFilter<SentryLoggerProvider>(_ => true) that each integration registers to let everything through.

This is the 6.x counterpart of #5869, which fixes the same bug on version7. It removes the alias from the three event providers (SentryLoggerProvider, SentryAspNetCoreLoggerProvider, SentryMauiLoggerProvider). The three *StructuredLoggerProvider types keep it, so Logging:Sentry:LogLevel still filters structured logs.

Behaviour change

Apps that silenced a category this way will get that category's breadcrumbs and events again. That's the behaviour 6.0.0 documented, so this ships as a fix rather than a breaking change. To drop them, use SentryLoggingOptions.AddLogEntryFilter, or MinimumBreadcrumbLevel / MinimumEventLevel.

Extra change on main: SDK options are still read from Logging:Sentry

On 6.x, Logging:Sentry also holds SDK configuration (Dsn, MinimumEventLevel, …). SentryLoggingOptionsSetup and SentryAspNetCoreOptionsSetup read it through ILoggerProviderConfiguration<SentryLoggerProvider> and <SentryAspNetCoreLoggerProvider>. That interface only sees Logging:Sentry through the provider's alias. Without the alias it sees just Logging:<full type name>, so an app with its Dsn under Logging:Sentry would silently run with the SDK disabled.

Both setups now read through the structured-log provider types, which keep the alias. #5869 makes the same switch for SentryLoggingOptionsSetup. version7 doesn't need it for ASP.NET Core, because there SentryAspNetCoreOptionsSetup already takes an IConfiguration. On main it's needed for both.

With the alias removed but no redirect, the existing ConfigurationOptionsTests and UseSentry_SentryAndLoggingSections_BindsOptions fail.

Merge note for version7

The next main → version7 merge will conflict in four files this PR touches, all of which version7 has restructured: SentryLoggingOptionsSetup.cs, SentryAspNetCoreOptionsSetup.cs, SentryAspNetCoreOptionsSetupTests.cs and LoggingBuilderExtensionsTests.cs. Keep the version7 side in each. That leaves every file this PR touches identical to version7.

Closes #5860

🤖 Generated with Claude Code

…er breadcrumbs and events

Remove [ProviderAlias("Sentry")] from the breadcrumb/event logger providers
so Logging:Sentry category rules only apply to structured logs, as 6.0.0
documented. Read SDK options through the structured-log providers, which
keep the alias, so Logging:Sentry:Dsn and friends still bind.

Backport of #5869 to 6.x.

Closes #5860

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.69%. Comparing base (a9b0062) to head (3c00562).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5872      +/-   ##
==========================================
+ Coverage   76.57%   76.69%   +0.11%     
==========================================
  Files         528      528              
  Lines       19624    19524     -100     
  Branches     3873     3840      -33     
==========================================
- Hits        15028    14973      -55     
+ Misses       3711     3668      -43     
+ Partials      885      883       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescrosswell
jamescrosswell marked this pull request as ready for review November 4, 2026 21:31
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 4, 2026

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5869 is merged now, so the "One catch" paragraph in the merge note can go. The merge also conflicts in SentryLoggerProviderTests.cs at the moment, which makes five files. With the suggestions below it's back to the four the note lists. Keeping the version7 side in each of them leaves every other file identical to version7.

Removes the SentryLoggerProvider alias test (as #5869 did on version7), the
structured-log and Logging:Sentry binding tests in LoggingBuilderExtensionsTests,
and the two ASP.NET Core UseSentry tests that would merge cleanly into version7
and then fail there. Existing tests already catch the alias coming back and the
options setup no longer reading Logging:Sentry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jamescrosswell
jamescrosswell merged commit ca07b6c into main Nov 5, 2026
60 checks passed
@jamescrosswell
jamescrosswell deleted the ai/logging-category-rules-6x-ce9181 branch November 5, 2026 20:33
jamescrosswell added a commit that referenced this pull request Nov 5, 2026
SentryLoggingOptionsSetup conflicted: main renamed the provider type parameter
to SentryStructuredLoggerProvider in both halves of the #if NET6_0_OR_GREATER
split (#5872), while this branch removed the #else half entirely. Kept the
removal and took the rename in the surviving half.

Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Category rules under Logging:Sentry:LogLevel also filter breadcrumbs and events

2 participants