Sentry's .NET SDK 7.0 is ready for .NET 11
Sentry’s .NET SDK 7.0 fully supports .NET 11, adds packages for generic hosts and Quartz.NET integrations… and has some breaking changes. For your app, this means:
- New to try:
UseSentry()for worker services and Azure Functions (isolated), cron monitors and tracing for Quartz.NET jobs, and .NET 11 support. - Code to change: apps where a
Serilog,NLogorlog4netintegration, orLogging.AddSentry(), sets the DSN, and Android, iOS, Mac Catalyst or MAUI apps still on .NET 9. - Update and check: apps that already start Sentry with
UseSentry()orSentrySdk.Initusually only need the new packages, plus a look at the logs, tracing and environment changes below.
If you’re not ready for the breaking changes yet, we also released the Quartz.NET packages, SentrySdk.WithMonitor, the Hangfire cron changes and UseSentry() on WebApplicationBuilder on version 6.13.0.
Move to .NET 11 and keep readable Android stack traces
You can move your apps to .NET 11 with 7.0, including Android, iOS and Mac Catalyst apps. .NET 11 Android apps can use a different assembly store layout and compress their assemblies with Zstandard, and the SDK reads both, so Sentry can still show file names and line numbers in your Android stack traces. 7.0 targets net11.0 alongside .NET 8, 9 and 10. On .NET 11, Android apps need API level 24 (Android 7.0) or later, and Mac Catalyst apps need 17.0 or later.
Android, iOS and Mac Catalyst apps, and MAUI apps on Windows, now need .NET 10 or later, because 7.0 drops net9.0-android, net9.0-ios, net9.0-maccatalyst and net9.0-windows. Other targets are unchanged: .NET 8 and later, .NET Standard 2.0 and 2.1, and .NET Framework 4.6.2. WPF and WinForms apps on .NET 9 keep working.
One place to initialize Sentry
7.0 gives your Sentry settings one home and stops duplicate errors. In version 6.x, each logging integration (Microsoft.Extensions.Logging, Serilog, NLog and log4net) could start the SDK. An app that called both UseSentry() and Logging.AddSentry() captured every error twice, and its SDK settings could end up spread across several places. Now the logging integrations only capture logs, breadcrumbs and events. You initialize Sentry in one place, with SentrySdk.Init or UseSentry().
If a logging integration still sets a DSN, the SDK tells you what to change, as a build error or at startup. We chose to fail loudly here because an integration that quietly stopped starting the SDK would leave your app sending nothing. The migration guide for initializing Sentry shows the setup before and after for each logging integration, including apps that called both UseSentry() and Logging.AddSentry(), and apps whose integrations reported crashes from Main before the host started.
Worker services and Azure Functions get the same one-line setup as ASP.NET Core
ASP.NET Core apps already had UseSentry(), while worker services and console apps usually started Sentry through the logging integrations.
The new Sentry.Extensions.Hosting package adds UseSentry() to Host.CreateApplicationBuilder and IHostBuilder, for worker services, console apps, Azure Functions (isolated) and Windows services. Install it with dotnet add package Sentry.Extensions.Hosting, then call UseSentry() on the builder:
var builder = Host.CreateApplicationBuilder(args);
builder.UseSentry(o => o.Dsn = "...");
builder.Services.AddHostedService<Worker>();
builder.Build().Run();The Generic Host guide covers the rest of the setup, such as appsettings.json, logs and capturing startup crashes.
ASP.NET Core apps can now also call builder.UseSentry(...) on WebApplicationBuilder.
Find out when a Quartz.NET job fails or stops running
Sentry.Quartz (for Quartz.NET 4.x) runs each job in its own scope and trace, tags it with the job key, and captures the exceptions thrown by jobs. Install it with dotnet add package Sentry.Quartz, then call AddSentry() in your Quartz configuration, as in this sample:
using Quartz;
using Sentry.Quartz;
// Initialize Sentry separately, for example with UseSentry()
services.AddQuartz(q => q.AddSentry());
[SentryMonitorSlug("nightly-report")]
public class NightlyReportJob : IJob { /* ... */ }Jobs with [SentryMonitorSlug] send a Crons check-in on every run and use the trigger’s cron or interval as the monitor config. If a job stops running, you get an alert, and you don’t have to set up the monitor by hand. The slug argument is optional. Without it, the monitor uses the job’s key. To monitor every job without adding the attribute, set MonitorAllJobs = true in AddSentry’s options.
Still on Quartz.NET 3.x? Sentry.Quartz3 supports 3.6 and later. It registers as a job listener and sends the same check-ins. Quartz.NET 3.x has no job middleware, though, so Sentry.Quartz3 doesn’t run each job in its own scope or capture the exceptions jobs throw.
Most of Sentry.Quartz started as a community contribution on GitHub, and we’re glad to ship it with this release.
Serilog, NLog and log4net logs reach Sentry without a flag
In 7.0, adding a logging integration is how you tell Sentry you want logs. You don’t also have to turn them on with a flag, so EnableLogs is no longer on SentryOptions.
Logs now show up in Sentry, on the same traces as your errors, as soon as you add a Serilog, NLog or log4net integration. Logging.AddSentry() does the same in apps that start Sentry with SentrySdk.Init. Logs you write with SentrySdk.Logger are always sent.
That means an upgraded app can send many more logs than it did in 6.x, including Debug and Information lines that may contain personal data. Check your logging framework’s minimum level before you upgrade. For NLog, that’s the target’s MinimumLogLevel, which defaults to Info.
To send fewer logs, filter them with SetBeforeSendLog. Returning null drops a log, so SetBeforeSendLog(_ => null) turns logs off.
Apps that start Sentry with UseSentry() work differently. In ASP.NET Core, MAUI, Blazor WebAssembly and generic host apps, UseSentry() adds the ILogger integration for you, so adding it doesn’t mean you asked for logs. That integration keeps its logs off by default. EnableLogs moved to the options of UseSentry(), so set it there or in the Sentry section of appsettings.json. A Serilog, NLog or log4net integration in the same app sends its logs either way.
SentryOptions.EnableMetrics is gone too. It has had no effect since 6.10.0, because the metrics you emit with SentrySdk.Metrics are always sent. If you still set it, delete the line.
Other changes
SentrySdk.WithMonitorandWithMonitorAsyncwrap any job in cron check-ins from code, and create the monitor with its schedule.- Hangfire recurring jobs marked with
[SentryMonitorSlug]send their cron schedule and time zone, so Sentry creates the monitor if it doesn’t exist yet. SetMonitorAllRecurringJobs = trueto monitor every recurring job. Existing monitors take their schedule and time zone from the job on its next run. To keep managing schedules in Sentry, setSendMonitorConfig = false. - Requests that end in 301, 305–399 or 401–404 are no longer traced by default, so auth failures and 404s stop cluttering your performance data. To change the list, edit
TraceIgnoreStatusCodes. - Blazor WebAssembly, Google Cloud Functions and apps that configure Sentry through
ISentryBuildernow report the host environment, such asdevelopmentorstaging, instead ofproductionwhen you don’t set one. Check alerts and filters that match onproduction.
Upgrading to 7.0
7.0 is a major release with breaking changes, so read up before you upgrade. Update every Sentry package in your solution to 7.0.0 at the same time.
The v6 to v7 migration guide covers every change, including the new minimum versions. Its interactive migration checklist lets you check off each step and remembers your progress. Both pages also have a prompt you can paste into your coding agent to start the migration. If you run into problems, open an issue on GitHub.