Repository navigation
feat(nlog): add MinimumLogLevel so Trace and Debug entries aren't sent as logs by default - #5913
Merged
Merged
Conversation
AddSentry() added a rule for every level, and every entry reaching the Sentry target is sent as a structured log. Apps that route ILogger through NLog therefore sent every Trace and Debug entry as a log. The new optional minLevel parameter sets the rule's lower bound; it defaults to Trace, so existing behaviour is unchanged. The ASP.NET Core NLog sample now uses AddSentry(minLevel: ...) instead of building the rule by hand. Closes #5909 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trace and Debug entries no longer reach the Sentry target unless minLevel says so, matching Microsoft.Extensions.Logging's usual Information default. The console sample lowers MinimumBreadcrumbLevel to Debug, so it now passes minLevel: Debug to keep those breadcrumbs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamescrosswell
commented
Nov 11, 2026
…mumLogLevel A rule bound also limits breadcrumbs and events, so Trace breadcrumbs couldn't be kept alongside Info-and-up logs. MinimumLogLevel sits next to MinimumEventLevel and MinimumBreadcrumbLevel, filters only structured logs, defaults to Info, and can be set from XML (minimumLogLevel="Debug"). AddSentry goes back to a rule for every level, with its 6.x signature. The EnableLogs messages now point at MinimumLogLevel=Off rather than SetBeforeSendLog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## version7 #5913 +/- ##
============================================
+ Coverage 76.98% 76.99% +0.01%
============================================
Files 538 538
Lines 19714 19719 +5
Branches 3872 3874 +2
============================================
+ Hits 15176 15182 +6
- Misses 3666 3667 +1
+ Partials 872 870 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ric-oliv
approved these changes
Nov 11, 2026
AddSentry added a rule for every level, so entries below all three minimum levels still reached the target and were dropped there. The rule now starts at the lowest of MinimumEventLevel, MinimumBreadcrumbLevel and MinimumLogLevel (Info by default). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changing options after setup isn't supported, so it doesn't need documenting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ric-oliv
reviewed
Nov 11, 2026
In 6.x enableLogs="false" turned logs off. It was only a warning in 7.0 because the target had no way to turn logs off; MinimumLogLevel now gives it one, so existing configs keep their meaning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LoggingConfiguration.AddSentry()adds a rule for every level, and in 7.0 every entry that reaches the Sentry target is sent as a structured log. Apps that routeILoggerthrough NLog (ReplaceLoggerFactory = true, as the 7.0 docs recommend alongsideUseSentry) therefore sent every ASP.NET CoreTraceandDebugentry to Sentry as a log.Whatever the fix, it has to let logs be filtered separately from breadcrumbs and events. An app that wants
Tracebreadcrumbs but onlyInfoand higher as logs should be able to have both.How the other integrations do it
MEL is the ideal. Logs come from their own provider,
SentryStructuredLoggerProvider, aliasedSentry. Breadcrumbs and events come fromSentryLoggerProvider. So the standardLoggingconfiguration filters logs on their own:NLog can't do that. A single
SentryTargetsends events, breadcrumbs and logs, and NLog's rules (AddRule,minlevel,<filters>) decide what reaches the target as a whole. A rule can't let an entry through for breadcrumbs and hold it back from logs.Serilog splits the job in two:
RestrictedToMinimumLevelgates everything that reaches the sink.MinimumEventLevelandMinimumBreadcrumbLevelset thresholds for each kind of data.What this PR does
It follows Serilog's approach, with NLog's rules as the gate:
RestrictedToMinimumLevel. It decides what reaches the Sentry target at all, as it always has.AddSentry()now starts its rule at the lowest of the three minimum levels instead of adding one for every level, so entries the target would drop never reach it.SentryNLogOptionsgetsMinimumLogLevel, next toMinimumEventLevelandMinimumBreadcrumbLevel. It defaults toInfoand only filters logs.Serilog has no threshold for logs, so there the sink-wide gate is the only way to filter them.
MinimumLogLevelgives NLog the separation MEL gets from its two providers:It's also a target attribute,
minimumLogLevel="Debug", for XML config. With theInfodefault, the docs can go back to a plainconfig.AddSentry(...)(getsentry/sentry-docs#19925). The ASP.NET Core NLog sample now usesAddSentryinstead of building the rule by hand.Worth flagging in review
TraceandDebugentries are no longer sent as logs unlessMinimumLogLevelis lowered. This applies to XML-configured targets too.enableLogs="false"now setsMinimumLogLeveltoOff, so configs carried over from 6.x keep turning logs off. Before this PR it only wrote a warning.EnableLogsstays[Obsolete], pointing toMinimumLogLevel.AddSentry's signature is unchanged), so the title has no!. Add it if the default change should be listed under Breaking Changes.Closes #5909
🤖 Generated with Claude Code