Repository navigation
Closed
getsentry/sentry-docs
#20311Labels
.NETPull requests that update .net codeDocsMicrosoft.Extensions.LoggingNext MajorChanges scheduled for the next Major release.
Description
#5739 added the Sentry.Extensions.Hosting package on version7, with UseSentry for generic-host apps, and closed #5572. #5740 then stopped Logging.AddSentry() from registering IHub and ISentryClient. This issue is the docs for both.
In 6.x, the only documented way to set up Sentry in a generic-host app (Host.CreateApplicationBuilder(), worker services, Windows services, console apps on the generic host) is builder.Logging.AddSentry(dsn), on the Microsoft.Extensions.Logging page. #5595 removed that path in 7.0.0.
The .NET docs aren't versioned, so the guide merges when 7.0.0 ships.
What to document
This follows the "Docs to write" list in #5739, checked against version7.
- Install
Sentry.Extensions.Hostingand callbuilder.UseSentry()onIHostApplicationBuilder(.NET 8 and later) orIHostBuilder, with settings from theSentrysection ofappsettings.jsonand the callback. Nobuilder.Logging.AddSentry()alongside it. - The SDK starts during
Build(), before any hosted service, even when the app clears or replaces the logger providers (fix(hosting): start the SDK during Build() even when the app clears or replaces logger providers #5772). It closes onApplicationStopped, so a host that's built but never started still reports. - The host environment becomes the Sentry environment unless one is set.
"Dsn": ""disables the SDK. - Logs from
ILoggerneedEnableLogs = true, as on the other host integrations. - On .NET Framework,
UseSentryis only onIHostBuilder. Apps onHost.CreateApplicationBuilder()there switch toHost.CreateDefaultBuilder(), or useSentrySdk.InitwithLogging.AddSentry(). Those that injectIHub,ISentryClientorFunc<IHub>then register them withHubAdapter.Instance(feat(mel)!: Logging.AddSentry() no longer registers IHub or ISentryClient #5740). - Web and MAUI apps use
UseSentryfromSentry.AspNetCoreorSentry.Maui. The generic call steps aside when both are present. With only the generic one, they miss request data and transactions, or UI breadcrumbs, and a warning says so. - Aspire's
AddServiceDefaults, and any helper declared in theMicrosoft.Extensions.Hostingnamespace, needs the staticSentryWebApplicationBuilderExtensions.UseSentry(web)call, or its MAUI twin. - Azure Functions (isolated) apps use the generic
UseSentry. ClearProviders()removes Sentry's logger providers if it runs afterUseSentry. CallUseSentryafter it, or callbuilder.Logging.AddSentry()after it to add Sentry's providers back (fix(logging): make Logging.AddSentry() work after UseSentry and ClearProviders() #5776). Skip that when NLog, Serilog or log4net already sends the app'sILoggerentries to Sentry, or each entry arrives twice (docs: add an ASP.NET Core NLog sample and stop advising AddSentry() when another integration handles ILogger #5821). WithDebug = true, the SDK warns when the providers were removed and not added back (fix(logging): warn when ClearProviders() removes the logger providers UseSentry added #5789).- Migrating: when adding
UseSentry, removeSentrySdk.Initand move its options into the callback or theSentrysection. Whichever init runs last wins, and options don't merge.
Where
- A new guide at
docs/platforms/dotnet/guides/extensions-hosting/(platform keydotnet.extensions-hosting), on the quick start template from feat(docs): Apply new quick start template to .NET quick start guides sentry-docs#19990. - Once it merges, link to it from the Microsoft.Extensions.Logging guide (docs(dotnet): Update Microsoft.Extensions.Logging guide for SDK 7.0.0 sentry-docs#19961) and the Azure Functions guide (docs(dotnet): Update logging docs for SDK 7.0.0 sentry-docs#19925), which also moves the Azure Functions guide to the generic
UseSentry. - The migration guide (docs(dotnet): Add 6.x to 7.x migration guide for 7.0.0-rc.2 sentry-docs#20143) already has upgrade entries for these changes.
Related: #2274 asks for better guidance for .NET Worker Services.
Metadata
Metadata
Assignees
Labels
.NETPull requests that update .net codeDocsMicrosoft.Extensions.LoggingNext MajorChanges scheduled for the next Major release.
Activity
linear-code commentedon Oct 12, 2026
NET-857
docs(dotnet): Add a Generic Host guide for SDK 7.0.0 (#20311)