Repository navigation
docs: add an ASP.NET Core NLog sample and stop advising AddSentry() when another integration handles ILogger - #5821
Merged
Merged
Conversation
…hen another integration handles ILogger The sample routes ILogger through NLog with ReplaceLoggerFactory, so Sentry's own ILogger providers stand aside and each entry reaches Sentry once. The ClearProviders() warning and the AddSentry() remarks told apps to add Sentry's providers back, which sends every entry twice when NLog, Serilog or log4net already forward ILogger entries to Sentry. Refs #5763 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## version7 #5821 +/- ##
============================================
+ Coverage 76.17% 76.22% +0.04%
============================================
Files 526 528 +2
Lines 19265 19318 +53
Branches 3729 3737 +8
============================================
+ Hits 14676 14726 +50
Misses 3734 3734
- Partials 855 858 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… Core NLog sample Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamescrosswell
commented
Oct 28, 2026
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.
Adds an ASP.NET Core sample for NLog and changes the guidance that sends
ILoggerentries to Sentry twice.Sentry.Samples.AspNetCore.NLog: routesILoggerthrough NLog withUseNLog(new NLogAspNetCoreOptions { ReplaceLoggerFactory = true }). NLog's factory replaces the default one, so theILoggerproviders thatUseSentryadds never run, and each entry reaches Sentry once, through the NLog target, in either call order. NLog's defaultUseNLog()adds a provider instead, which duplicates every entry (see the issue).HostLoggerProvidersRemovedwarning: it led with "callAddSentry()to add them back". When NLog, Serilog or log4net already forwardILoggerentries to Sentry, doing that sends each entry twice. The warning now leads with that case.Logging.AddSentry()remarks (both overloads): say plainly that apps callingUseSentrydon't need it, and that it's for adding Sentry's providers back afterClearProviders().Part of #5763. The sentry-docs changes listed in the issue are separate.
Note: with
Debugturned on, this sample (and anyUseNLog()+UseSentryapp onversion7) crashes with a stack overflow. The SDK's diagnostic logs go throughILoggerto the NLog Sentry target, which logs diagnostics again. That isn't caused by this PR; it's tracked in #5822.#skip-changelog
🤖 Generated with Claude Code