Repository navigation
Closed
getsentry/sentry-docs
#20715Labels
.NETPull requests that update .net codePull requests that update .net codeDocsFramework: ASP.NET CoreMicrosoft.Extensions.LoggingNext MajorChanges scheduled for the next Major release.Changes scheduled for the next Major release.State: Needs Discussion
Description
The Generic Host guide (getsentry/sentry-docs#20311) explains what ClearProviders() does to Sentry's logger providers. The ASP.NET Core guide (docs/platforms/dotnet/guides/aspnetcore/index.mdx) doesn't mention it, but ASP.NET Core's UseSentry registers its providers the same way, so the same advice applies. Raised by @ric-oliv in the review of getsentry/sentry-docs#19961.
Behaviour on version7
Read from version7 (51e7d99), not from running an app:
IWebHostBuilder.UseSentryregistersSentryAspNetCoreLoggerProviderandSentryAspNetCoreStructuredLoggerProviderthroughHostLoggerProviders.Add(src/Sentry.AspNetCore/SentryWebHostBuilderExtensions.cs:87), as the Generic Host does (src/Sentry.Extensions.Hosting/SentryHostBuilderExtensions.cs:163).WebApplicationBuilder.UseSentrycalls it.builder.Logging.ClearProviders()afterUseSentryremoves both providers, soILoggerentries no longer become breadcrumbs, events or structured logs.- The SDK still starts and the middleware is still added, because
SentryStartupFiltercallsIApplicationBuilder.UseSentry(src/Sentry.AspNetCore/ApplicationBuilderExtensions.cs:47-50). - That method also runs
HostLoggerProviders.WarnIfRemoved. The warning goes to the diagnostic logger, so it only shows withDebug = true. builder.Logging.AddSentry()afterClearProviders()adds the ASP.NET Core providers back, using theUseSentryoptions (src/Sentry.Extensions.Logging/LoggingBuilderExtensions.cs:65-88).
What to add
A short section in the ASP.NET Core guide, matching the Generic Host one:
- Call
ClearProviders()beforeUseSentry. - If the app has to clear providers after
UseSentry, callbuilder.Logging.AddSentry()afterClearProviders(). Skip that if NLog, Serilog or log4net already sendsILoggerentries to Sentry, because each entry would then arrive twice.
The AddSentry() re-add and the warning are new in 7.0.0, so this targets dotnet-v7 in getsentry/sentry-docs.
Metadata
Metadata
Assignees
Labels
.NETPull requests that update .net codePull requests that update .net codeDocsFramework: ASP.NET CoreMicrosoft.Extensions.LoggingNext MajorChanges scheduled for the next Major release.Changes scheduled for the next Major release.State: Needs Discussion
Activity
linear-code commentedon Nov 11, 2026
NET-923
docs(dotnet): Document ClearProviders() in the ASP.NET Core guide for…
jamescrosswell commentedon Nov 11, 2026
Done in getsentry/sentry-docs#20715, merged into
dotnet-v7. It goes live when that branch merges intomasterwith 7.0.0 (getsentry/sentry-docs#20641).