Repository navigation
docs(dotnet): Add a Generic Host guide for SDK 7.0.0 - #20311
jamescrosswell wants to merge 2 commits into
Conversation
Documents Sentry.Extensions.Hosting, which sentry-dotnet 7.0.0 adds: UseSentry on IHostApplicationBuilder and IHostBuilder, configuration, environment, startup and shutdown, ClearProviders(), web and MAUI apps, Aspire service defaults, the .NET Framework gap and replacing SentrySdk.Init. Adds a config intro for the guide's options page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
The new Generic Host guide (#20311) starts Sentry with UseSentry, so its logs usage page should show the ILogger section like the other host integrations, and its requirements start at 7.0.0. Also say that generic host apps set EnableLogs to send ILogger entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| } | ||
| ``` | ||
|
|
||
| `EnableLogs` doesn't change how errors and breadcrumbs are captured. Entries at `Error` and above are sent as events, and entries at `Information` and above are kept as breadcrumbs. To change that, set `MinimumEventLevel` and `MinimumBreadcrumbLevel`. |
There was a problem hiding this comment.
AddLogEntryFilter works on the UseSentry options too. If #19961 drops its Generic Host content, this page is the only place left that shows it. Maybe something like:
| `EnableLogs` doesn't change how errors and breadcrumbs are captured. Entries at `Error` and above are sent as events, and entries at `Information` and above are kept as breadcrumbs. To change that, set `MinimumEventLevel` and `MinimumBreadcrumbLevel`. | |
| `EnableLogs` doesn't change how errors and breadcrumbs are captured. Entries at `Error` and above are sent as events, and entries at `Information` and above are kept as breadcrumbs. To change that, set `MinimumEventLevel` and `MinimumBreadcrumbLevel`. | |
| To drop specific entries before they become breadcrumbs or events, add a filter with `AddLogEntryFilter`. Return `true` to drop the entry: | |
| ```csharp {filename:Program.cs} | |
| using Sentry.Extensions.Logging; | |
| builder.UseSentry(options => | |
| { | |
| options.AddLogEntryFilter((category, level, eventId, exception) => | |
| exception is OperationCanceledException); | |
| }); | |
| ``` |
There was a problem hiding this comment.
To drop specific entries before they become breadcrumbs or events, add a filter with
AddLogEntryFilter
This bit's good. We could link to the docs for that option rather than trying to re-explain it here (which means two different copies of the same explanation to keep in sync)?
There was a problem hiding this comment.
Maybe just this?
| `EnableLogs` doesn't change how errors and breadcrumbs are captured. Entries at `Error` and above are sent as events, and entries at `Information` and above are kept as breadcrumbs. To change that, set `MinimumEventLevel` and `MinimumBreadcrumbLevel`. | |
| `EnableLogs` doesn't change how errors and breadcrumbs are captured. Entries at `Error` and above are sent as events, and entries at `Information` and above are kept as breadcrumbs. To change that, set `MinimumEventLevel` and `MinimumBreadcrumbLevel`. | |
| To drop specific entries before they become breadcrumbs or events, call [`AddLogEntryFilter`](/platforms/dotnet/guides/extensions-logging/#filters) in the `UseSentry` callback. |
#19961 renames that heading to Log Entry Filters, so it'd need to update this anchor when it lands.
There was a problem hiding this comment.
Yeah that looks cleaner 👍🏻
Refs getsentry/sentry-dotnet#5844 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Warning
Do not merge before sentry-dotnet 7.0.0 is released (planned 2026-11-30).
DESCRIBE YOUR PR
Adds a Generic Host guide for
Sentry.Extensions.Hosting, which sentry-dotnet 7.0.0 adds (getsentry/sentry-dotnet#5739). In 7.0.0,Logging.AddSentry()no longer initializes the SDK. Worker services, console apps on the generic host, Windows services and Azure Functions (isolated) apps callUseSentryfrom this package instead. The page is written for 7.x. The docs aren't versioned, so this stays a draft until 7.0.0 ships.The guide follows the quick start template from #19990 and covers:
UseSentryonIHostApplicationBuilderandIHostBuilder, theSentryandLogging:Sentrysections, and why not to callLogging.AddSentry()as well"Dsn": "", and when the SDK starts (Build()) and closes (ApplicationStopped)ClearProviders()ordering (fix(hosting): start the SDK during Build() even when the app clears or replaces logger providers sentry-dotnet#5772, fix(logging): make Logging.AddSentry() work after UseSentry and ClearProviders() sentry-dotnet#5776, fix(logging): warn when ClearProviders() removes the logger providers UseSentry added sentry-dotnet#5789, docs: add an ASP.NET Core NLog sample and stop advising AddSentry() when another integration handles ILogger sentry-dotnet#5821)UseSentrycall that Aspire'sAddServiceDefaultsneedsSentrySdk.InitandLogging.AddSentry()fallback and itsHubAdapter.Instanceregistrations (feat(mel)!: Logging.AddSentry() no longer registers IHub or ISentryClient sentry-dotnet#5740)SentrySdk.Init, briefly. The migration guide (docs(dotnet): Add 6.x to 7.x migration guide for 7.0.0-rc.2 #20143) covers upgrades.It also adds
platform-includes/configuration/config-intro/dotnet.extensions-hosting.mdx, so the guide's Options page starts withUseSentryinstead ofSentrySdk.Init.Closes getsentry/sentry-dotnet#5707
Notes for review
index.mdx. The platform keydotnet.extensions-hostingcomes from the folder name, guides withoutsidebar_order, like the other .NET guides, are listed by title, and the icon falls back to the .NET one, as for the Microsoft.Extensions.Logging, Serilog and NLog guides. The page is new, so it needs no redirects.packages.version('sentry.dotnet'), because the release registry has nosentry.dotnet.extensions.hostingentry yet. Until 7.0.0 is out, the preview shows 6.12.1, which doesn't exist for this package. Once the registry has the package, switch to its own key. Thesdk:frontmatter already usessentry.dotnet.extensions.hosting(fromConstants.cs). Without a registry entry, the page just has no package details box.dotnet.extensions-hosting. I left them alone, since other PRs own them:platform-includes/logs/setup/dotnet.mdxfalls into theSentrySdk.Initsection instead ofUseSentrywithEnableLogs. docs(dotnet): Update logging docs for SDK 7.0.0 #19925 is adding the key to the host sections.platform-includes/logs/options/dotnet.mdxshows the genericEnableLogstext and leaves out "Configure Microsoft.Extensions.Logging Filters". Same PR.platform-includes/logs/usage/dotnet.mdxshows only theSentrySdk.LoggerAPIs. The key belongs in theILoggersection too.platform-includes/logs/requirements/dotnet.mdxsays logs need SDK version 5.14.0. This package starts at 7.0.0.version7source:"Dsn": ""turns the SDK off, butSENTRY_DSNstill wins over an emptyDsn(SettingLocator.GetDsn). The page says so.Logging:Sentryonly acceptsLogLevel,MinimumBreadcrumbLevelandMinimumEventLevel. Any other key makesBuild()throwNotSupportedException. With no DSN anywhere,Build()throwsArgumentNullException.Sentry.AspNetCore'sUseSentrytwice still sends each error twice (a follow-up in feat: add Sentry.Extensions.Hosting with UseSentry for generic host apps sentry-dotnet#5739). The Aspire section says not to call it again inProgram.cs.logging.AddSentry(...). docs(dotnet): Update logging docs for SDK 7.0.0 #19925 owns it.Sentry.Samples.GenericHostsample link belongs here too, since the sample now callsUseSentry.UseSentrysetup.platform-includes/logs/integrations/dotnet.mdx: add Generic Host to the list.docs/product/logs/getting-started/index.mdxanddocs/product/metrics/getting-started/index.mdx: add Generic Host to the .NET lists.main, whereSentry.Samples.GenericHostkeeps the 6.x setup untilversion7is merged.version7, on net10.0, and on net48 for theIHostBuilderexample and the .NET Framework fallback. On net48,UseSentryonHostApplicationBuilderfails with CS1929, as the page says.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-DDwith the due date. You can update this information later by editing the PR description.🤖 Generated with Claude Code