Skip to content

docs(dotnet): Document ClearProviders() in the ASP.NET Core guide for SDK 7.0.0 - #20715

Merged
jamescrosswell merged 2 commits into
dotnet-v7from
dotnet-v7-aspnetcore-clearproviders
Nov 11, 2026
Merged

jamescrosswell merged 2 commits into
dotnet-v7from
dotnet-v7-aspnetcore-clearproviders

Conversation

@jamescrosswell

Copy link
Copy Markdown
Collaborator

Note

This targets dotnet-v7, which collects the .NET docs for sentry-dotnet 7.0.0. #20641 merges that branch into master when 7.0.0 ships, so this PR can merge into dotnet-v7 as soon as it's approved.

DESCRIBE YOUR PR

Adds a "Clearing Logger Providers" section to the ASP.NET Core guide, matching the one in the Generic Host guide (#20311). ASP.NET Core's UseSentry registers Sentry's logger providers the same way, so ClearProviders() after it removes them and ILogger entries stop reaching Sentry. The section says to call UseSentry after ClearProviders(), or to add the providers back with builder.Logging.AddSentry().

Closes getsentry/sentry-dotnet#5911

Notes for review

  • Checked with a web app on Sentry.AspNetCore 7.0.0-rc.3. version7 hasn't changed this code since rc.3.
    • ClearProviders() before UseSentry: a logged warning becomes an event.
    • ClearProviders() after UseSentry: the SDK starts, but the warning doesn't reach Sentry. With Debug on, the SDK logs the "logger providers were removed" warning during StartAsync.
    • AddSentry() after ClearProviders(): the warning becomes an event again, using MinimumEventLevel from the UseSentry options.
    • Both snippets compile on net10.0.
  • The Generic Host guide says the warning comes "during Build()". Here it's "when the app starts", because ASP.NET Core starts the SDK when the host starts (Start the SDK during Build() in ASP.NET Core and Blazor WebAssembly, as the generic host does sentry-dotnet#5815).
  • The snippet uses builder.WebHost.UseSentry() to match the rest of this page, which doesn't use the 7.0 builder.UseSentry() overload yet.

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.
Select exactly one option. For deadlines, replace YYYY-MM-DD with the due date. You can update this information later by editing the PR description.

  • Urgent deadline (GA date, etc.): 2026-11-30
  • Other deadline: YYYY-MM-DD
  • No deadline: Not urgent, can wait up to 1 week+

🤖 Generated with Claude Code

ClearProviders() after UseSentry removes Sentry's logger providers, as
it does for the Generic Host. Mirror the Generic Host guide's section:
call UseSentry after ClearProviders(), or add the providers back with
Logging.AddSentry().

Closes getsentry/sentry-dotnet#5911

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-docs Ready Ready Preview Nov 11, 2026 9:20pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
develop-docs Ignored Ignored Preview Nov 11, 2026 9:20pm UTC

Request Review

@github-actions github-actions Bot added the Priority: Urgent Docs review is needed immediately for an urgent deadline label Nov 11, 2026
@codeowner-assignment
codeowner-assignment Bot requested a review from a team November 11, 2026 02:52
@jamescrosswell
jamescrosswell marked this pull request as ready for review November 11, 2026 02:59
@codeowner-assignment
codeowner-assignment Bot requested a review from a team November 11, 2026 03:00
@cursor

cursor Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Getting ready to monitor this change · Rollout details

Status Service Environment
⏳ Getting ready to monitor this change

@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.

Looks good!

One optional suggestion inline.

Not for this PR: MAUI and Blazor WebAssembly register their providers through the same HostLoggerProviders.Add (MAUI, WASM). So ClearProviders() after UseSentry removes them there too, and AddSentry() adds them back. Neither one calls WarnIfRemoved, so they log no warning, and neither guide mentions it. It's probably rare, since the MAUI template doesn't clear providers, so it only needs an issue if you think it's worth it.

Co-authored-by: Ricardo Colombo Oliveira <github@ricoliv.com>
@codeowner-assignment
codeowner-assignment Bot requested a review from a team November 11, 2026 21:13
@jamescrosswell
jamescrosswell merged commit cc6ae0b into dotnet-v7 Nov 11, 2026
12 checks passed
@jamescrosswell
jamescrosswell deleted the dotnet-v7-aspnetcore-clearproviders branch November 11, 2026 21:20
@ric-oliv ric-oliv mentioned this pull request Nov 13, 2026
6 of 8 tasks
ric-oliv added a commit that referenced this pull request Nov 15, 2026
## DESCRIBE YOUR PR

This updates the .NET docs for sentry-dotnet 7.0.0, which has been on
NuGet since 2026-11-12. Each change was reviewed in its own PR against
the `dotnet-v7` branch, so the 7.x docs go live together:

- #20311 docs(dotnet): Add a Generic Host guide for SDK 7.0.0
- #20642 docs(dotnet): Add supported versions to the MAUI guide for SDK
7.0.0
- #19960 docs(dotnet): Document release and environment resolution for
SDK 7.0.0
- #19961 docs(dotnet): Update Microsoft.Extensions.Logging guide for SDK
7.0.0
- #19924 docs(dotnet): Update OTLP propagation docs for SDK 7.0.0
- #19925 docs(dotnet): Update logging docs for SDK 7.0.0
- #20715 docs(dotnet): Document ClearProviders() in the ASP.NET Core
guide for SDK 7.0.0
- #20752 docs(dotnet): Tell .NET Framework apps to install
Microsoft.Extensions.Logging for SDK 7.0.0
- #20743 docs(dotnet): Document NLog's MinimumLogLevel for SDK 7.0.0
- #20742 docs(dotnet): Link the Generic Host guide from the other .NET
pages for SDK 7.0.0
- #20689 docs(dotnet): Update the 7.x migration guide for 7.0.0
- #20780 docs(dotnet): Fix Serilog flushing, Serilog usings and the
Azure Functions package for SDK 7.0.0
- #20781 docs(dotnet): Fix the .NET logs and metrics examples and other
pages for SDK 7.0.0

### Issues this closes

Closes getsentry/sentry-dotnet#5710

The other docs issues for 7.0.0 were closed when their PRs merged into
`dotnet-v7`.

### Before merging

- [x] sentry-dotnet 7.0.0 is on NuGet.
- [x] The release candidate alert is gone from
`includes/dotnet-v7-migration-overview.mdx`.
- [x] The links that #20311, #19961 and #19925 left for after the other
PRs merge are in.
- [x] `master` is merged into `dotnet-v7`, and the Vercel preview looks
right.
- [x] This description has a `Closes` line for every issue that's still
open.

## IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs
to go live.
Select exactly one option. For deadlines, replace `YYYY-MM-DD` with the
due date. You can update this information later by editing the PR
description.

- [x] Urgent deadline (GA date, etc.): 2026-11-13
- [ ] Other deadline: YYYY-MM-DD
- [ ] No deadline: Not urgent, can wait up to 1 week+

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
Co-authored-by: ric-oliv <ric-oliv@users.noreply.github.com>
Co-authored-by: ric-oliv <5938598+ric-oliv@users.noreply.github.com>
Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>

This branch was successfully deployed

1 active deployment
Preview – sentry-docs — 07ed0300 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Urgent Docs review is needed immediately for an urgent deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document ClearProviders() in the ASP.NET Core guide for v7.0.0

2 participants