Skip to content
8 changes: 8 additions & 0 deletions docs/platforms/dotnet/common/migration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ sidebar_section: configuration

Upgrading includes both breaking changes and new features.

<PlatformSection notSupported={["dotnet.xamarin"]}>

## Migrating to 7.x

See the <PlatformLink to="/migration/v6-to-v7/">6.x to 7.x migration guide</PlatformLink> for every change, or use the <PlatformLink to="/migration/v6-to-v7/interactive/">interactive migration checklist</PlatformLink> to track your progress.

</PlatformSection>

## Migrating to 6.x

### .NET Target Framework Changes
Expand Down
129 changes: 129 additions & 0 deletions docs/platforms/dotnet/common/migration/v6-to-v7/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
title: Migrate from 6.x to 7.x
sidebar_order: 1
description: "Learn how to migrate your app from version 6.x to 7.x of the Sentry SDK for .NET."
notSupported:
- dotnet.xamarin
---

<Include name="dotnet-v7-agent-migration" />

<Include name="dotnet-v7-migration-overview" />

<Alert title="Prefer a checklist?" level="info">

The [Interactive 7.x Migration Guide](./interactive/) lets you check off completed migration steps.

</Alert>

## Versions and Packages

### Supported .NET Versions and Platforms

<Include name="migration/dotnet-v7/supported-net-versions-and-platforms" />

### Update All Sentry Packages Together

<Include name="migration/dotnet-v7/update-all-sentry-packages-together" />

## Initializing Sentry

### Logging Integrations No Longer Initialize Sentry

<Include name="migration/dotnet-v7/logging-integrations-no-longer-initialize-sentry" />

### Generic Host Apps Call UseSentry

<Include name="migration/dotnet-v7/generic-host-apps-call-usesentry" />

### Logging Options Only Set Log Levels

<Include name="migration/dotnet-v7/logging-options-only-set-log-levels" />

### IHub Is Registered Only by UseSentry

<Include name="migration/dotnet-v7/ihub-is-registered-only-by-usesentry" />

### Remove Redundant Logging.AddSentry Calls

<Include name="migration/dotnet-v7/remove-redundant-loggingaddsentry-calls" />

### Move SDK Settings Out of the Serilog Sink

<Include name="migration/dotnet-v7/move-sdk-settings-out-of-the-serilog-sink" />

### Move SDK Settings Out of the NLog Target

<Include name="migration/dotnet-v7/move-sdk-settings-out-of-the-nlog-target" />

### Move SDK Settings Out of the log4net Appender

<Include name="migration/dotnet-v7/move-sdk-settings-out-of-the-log4net-appender" />

## Logs and Metrics

### EnableLogs Is Removed from SentryOptions

<Include name="migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions" />

### Logging Integrations Send Logs

<Include name="migration/dotnet-v7/logging-integrations-send-logs" />

### Logging Frameworks No Longer Close Sentry

<Include name="migration/dotnet-v7/logging-frameworks-no-longer-close-sentry" />

### EnableMetrics Is Removed

<Include name="migration/dotnet-v7/enablemetrics-is-removed" />

## Tracing and OpenTelemetry

### Some Requests Are No Longer Traced

<Include name="migration/dotnet-v7/some-requests-are-no-longer-traced" />

### The OpenTelemetry Exporter No Longer Sets a Propagator

<Include name="migration/dotnet-v7/the-opentelemetry-exporter-no-longer-sets-a-propagator" />

## Release, Environment and SDK Name

### Release and Distribution Are Set on Options

<Include name="migration/dotnet-v7/release-and-distribution-are-set-on-options" />

### More Apps Report the Host Environment

<Include name="migration/dotnet-v7/more-apps-report-the-host-environment" />

### SDK Name, Release and Scope Environment

<Include name="migration/dotnet-v7/sdk-name-release-and-scope-environment" />

## Requests to Sentry

### DecompressionMethods No Longer Includes Brotli

<Include name="migration/dotnet-v7/decompressionmethods-no-longer-includes-brotli" />

## Integrations

### UseSentry Overrides appsettings.json in MAUI

<Include name="migration/dotnet-v7/usesentry-overrides-appsettingsjson-in-maui" />

### Hangfire Sends Recurring Job Schedules

<Include name="migration/dotnet-v7/hangfire-sends-recurring-job-schedules" />

## Other Removed and Internal APIs

<Include name="migration/dotnet-v7/other-removed-and-internal-apis" />

## Optional Cleanup

### Call UseSentry on WebApplicationBuilder

<Include name="migration/dotnet-v7/call-usesentry-on-webapplicationbuilder" />
25 changes: 25 additions & 0 deletions docs/platforms/dotnet/common/migration/v6-to-v7/interactive.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Interactive 7.x Migration Guide
sidebar_order: 2
description: "Migrate from version 6.x to 7.x of the Sentry SDK for .NET with an interactive checklist."
notSupported:
- dotnet.xamarin
---

<Include name="dotnet-v7-agent-migration" />

<Include name="dotnet-v7-migration-overview" />

This checklist covers the 7.x migration. Some steps only apply to specific integrations, platforms or configuration options. Check off a step after you complete it or confirm that it doesn't apply to your app. This browser saves your progress.

For details about each change, see the [migration guide](../).

<Alert level="warning">

The compiler won't catch every change. Read through the steps before upgrading, including the changes to logs, tracing and the reported environment.

</Alert>

## Your Migration Steps

<MigrationGuide migration="dotnet-v7" />
5 changes: 5 additions & 0 deletions includes/dotnet-v7-agent-migration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<AgentMigrationCallout
guideUrl="migration/v6-to-v7.md"
prompt="Upgrade this project from the Sentry SDK for .NET 6.x to 7.x. Inspect its Sentry NuGet packages, target frameworks, hosting model, logging integrations and how it initializes Sentry. Apply every migration step that applies to this project. Initialize Sentry once with UseSentry or SentrySdk.Init, and move the DSN and other SDK settings out of the logging integrations and the Logging:Sentry configuration section. Preserve the intended telemetry behavior, including the logs the app sends, the requests it traces and the environment it reports. Verify the migration with dotnet build and the project's existing tests, then run the app once and confirm that Sentry initializes, for example with Debug enabled, because a build alone doesn't catch a logging integration that sends nothing. Summarize the changes and any remaining manual steps."
description="Copy this prompt into your AI agent to migrate to 7.x."
/>
27 changes: 27 additions & 0 deletions includes/dotnet-v7-migration-overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Alert level="warning" title="Release candidate">

There is no stable 7.0 release of the Sentry SDK for .NET yet. The current release candidate is `7.0.0-rc.2`. Until 7.0.0 ships, use that version wherever this guide says `7.0.0`. The rest of the .NET docs still describe 6.x until then, so where they differ from this guide, follow this guide. If you run into problems, [open an issue on GitHub](https://github.com/getsentry/sentry-dotnet/issues).

On `7.0.0-rc.2`, three things work differently from what this guide describes:

- `Logging.AddSentry()` after `ClearProviders()` doesn't add Sentry's logger providers back. Call `UseSentry` after `ClearProviders()` instead.
- `DecompressionMethods` still includes Brotli, which the next release takes out of the default. To leave it out now, set `options.DecompressionMethods = DecompressionMethods.GZip | DecompressionMethods.Deflate` where you initialize Sentry.
- An ASP.NET Core app that sends `ILogger` entries through NLog crashes with a stack overflow when `Debug` is on. In these apps, leave `Debug` off and check that the test event arrives in Sentry instead.

The release candidate's `net11.0` builds depend on the .NET 11 release candidate versions of `Microsoft.Extensions.Http`, `Microsoft.Extensions.Logging.Configuration` and `Microsoft.Extensions.Configuration.Binder`. A .NET 11 app that references 10.0.x of one of these packages directly fails to restore with error NU1605. Remove that reference, or update it to the same .NET 11 release candidate version.

</Alert>

Version 7 of the Sentry SDK for .NET adds support for .NET 11 and moves SDK initialization out of the logging integrations. The biggest changes are:

- **One place to initialize Sentry.** The Serilog, NLog, log4net and `Microsoft.Extensions.Logging` integrations no longer start the SDK. Call `UseSentry` or `SentrySdk.Init` first, and move the DSN and other SDK settings there.
- **`UseSentry` for generic host apps.** Worker services, Azure Functions isolated worker apps and other apps on the .NET Generic Host can now call `UseSentry` from the new `Sentry.Extensions.Hosting` package.
- **Logs.** Version 7 removes `SentryOptions.EnableLogs`. Structured logs are now enabled automatically if you add the Serilog, NLog or log4net integrations, or call `Logging.AddSentry()` after `SentrySdk.Init`, so check the volume and content of your logs after upgrading if you use any of these integrations.
- **Platforms.** Android, iOS, Mac Catalyst and MAUI apps need .NET 10 or later.
- **Defaults.** The SDK traces fewer incoming requests, and more apps report the host environment instead of `production`.

Upgrade to the latest 6.x release first, and fix its obsolete warnings. Some APIs that 7.0 removes, such as `EnableMetrics` and the iOS option `EnableAppHangTrackingV2`, are already obsolete in 6.x.

The `Sentry.OpenTelemetry` package has been obsolete since 6.12.0. Code using this integration, such as `AddSentry()` on the tracer provider builder with `options.UseOpenTelemetry()`, still compiles on 7.0, but you will get warnings. The package will not see any future improvements or bug fixes, and it will be removed in a future version. Its replacement is the OTLP exporter from `Sentry.OpenTelemetry.Exporter`, with `AddSentryOtlpExporter` and `UseOtlp`. See [OpenTelemetry (OTLP)](/platforms/dotnet/tracing/instrumentation/opentelemetry-otlp/).

The compiler catches most of the changes. A few only show up at runtime or in your data. A logging integration sends nothing until you initialize Sentry. An app that calls `SentrySdk.Init` and injects `IHub` fails when the container resolves the service. The new defaults change log volume, traced requests and the reported environment. Read the behavior changes before you upgrade.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
id: call-usesentry-on-webapplicationbuilder
title: "Call UseSentry on WebApplicationBuilder"
phase: cleanup
category: rename
severity: informational
frameworks: all
platformCategory: all
order: 10
---

ASP.NET Core apps can now call `UseSentry` on `WebApplicationBuilder` and keep chaining. `builder.WebHost.UseSentry()` still works, so this change is optional.

In 6.x, `UseSentry` was only available on the web host:

```csharp {filename:Program.cs}
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseSentry(options => options.Dsn = "___PUBLIC_DSN___");
```

In 7.x, call it on the builder:

```csharp {filename:Program.cs}
var builder = WebApplication.CreateBuilder(args);
builder.UseSentry(options => options.Dsn = "___PUBLIC_DSN___");
```

A helper declared in the `Microsoft.Extensions.Hosting` namespace needs a static call instead. The `AddServiceDefaults` method that .NET Aspire templates generate is one example. Inside that namespace, `web.UseSentry()` binds to the generic host overload from `Sentry.Extensions.Hosting`, even for a `WebApplicationBuilder`. The app then misses request data, the middleware and the transactions for incoming requests. Call the ASP.NET Core overload as a static method:

```csharp {filename:Extensions.cs}
using Microsoft.AspNetCore.Builder;

namespace Microsoft.Extensions.Hosting;

public static class Extensions
{
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
{
if (builder is WebApplicationBuilder web)
{
SentryWebApplicationBuilderExtensions.UseSentry(web);
}
else
{
builder.UseSentry();
}

return builder;
}
}
```

When `UseSentry` from `Sentry.Extensions.Hosting` runs in an ASP.NET Core app, the SDK logs a warning through `ILogger` when the host starts.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
id: decompressionmethods-no-longer-includes-brotli
title: "DecompressionMethods No Longer Includes Brotli"
phase: verify
category: behavior
severity: informational
frameworks: all
platformCategory: all
order: 80
---

`SentryOptions.DecompressionMethods` now defaults to `GZip | Deflate`. In 6.x, it included every method, so the SDK asked your Sentry server for Brotli-compressed responses and decoded them. Sentry's responses to the SDK are small, so this shouldn't make a visible difference.

The new default keeps the SDK away from the .NET Brotli decoder, which has a security issue in unpatched runtimes. See [CVE-2026-111497](https://github.com/dotnet/announcements/issues/494). This matters most for self-contained, Native AOT and mobile apps, which carry their own runtime.

To accept Brotli-compressed responses again, add it back. `DecompressionMethods.Brotli` is available on .NET Core 3.0 and later:

```csharp {filename:Program.cs}
using System.Net;

SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.DecompressionMethods |= DecompressionMethods.Brotli;
});
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
id: enablelogs-is-removed-from-sentryoptions
title: "EnableLogs Is Removed from SentryOptions"
phase: code-changes
category: removed-api
severity: action-required
frameworks: all
platformCategory: all
order: 90
---

Version 7 removes `EnableLogs` from `SentryOptions`, the core options of the SDK, so setting it in `SentrySdk.Init` fails to compile with error CS1061. Remove the line.

Whether logs are on now depends on how your app writes them:

- **Logging integrations.** If you add the Serilog, NLog or log4net integration, or call `Logging.AddSentry()` after `SentrySdk.Init`, logs are on by default. Your logging framework's configuration, such as its minimum level, controls which entries they send. See [Logging Integrations Send Logs](#logging-integrations-send-logs).
- **Host integrations.** In ASP.NET Core, MAUI, Blazor WebAssembly and generic host apps, `UseSentry` adds an `ILogger` integration. It sends errors and breadcrumbs, but its logs are off by default. To turn them on, set `EnableLogs = true` on the options of `UseSentry`. `EnableLogs` doesn't affect a Serilog, NLog or log4net integration in the same app.
- **`SentrySdk.Logger`.** It sends logs in every app and needs no option.

In 6.x, `SentrySdk.Init` turned logs on:

```csharp {filename:Program.cs}
SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.EnableLogs = true;
});
```

In 7.x, remove `EnableLogs`:

```csharp {filename:Program.cs}
SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
});
```

In apps that call `UseSentry`, keep `EnableLogs` on its options to send `ILogger` entries as logs. You can also set it in the `Sentry` section of `appsettings.json`:

```csharp {filename:Program.cs}
var builder = WebApplication.CreateBuilder(args);
builder.UseSentry(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.EnableLogs = true;
});
```

A generic host app that set `EnableLogs` on `Logging.AddSentry` in 6.x sets it on `UseSentry` now.

The Serilog sink no longer takes an `enableLogs` argument. NLog's `enableLogs` setting no longer turns logs off, and setting it to `false` writes a warning to standard error. To drop logs and keep errors and breadcrumbs, use `SetBeforeSendLog`, as shown in [Logging Integrations Send Logs](#logging-integrations-send-logs).
34 changes: 34 additions & 0 deletions includes/migration/dotnet-v7/enablemetrics-is-removed.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
id: enablemetrics-is-removed
title: "EnableMetrics Is Removed"
phase: code-changes
category: removed-api
severity: action-required
frameworks: all
platformCategory: all
order: 100
---

Version 7 removes `SentryOptions.EnableMetrics`, so setting it fails to compile with error CS1061. The option has been obsolete and ignored since 6.10.0, because metrics are always on. To drop metrics, return `null` from `SetBeforeSendMetric`.

In 6.x, the obsolete option compiled but had no effect:

```csharp {filename:Program.cs}
SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.EnableMetrics = false;
});
```

In 7.x, drop metrics in the callback:

```csharp {filename:Program.cs}
SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.SetBeforeSendMetric(_ => null);
});
```

The SDK ignores an `EnableMetrics` key in the `Sentry` section of `appsettings.json`. Remove it.
Loading
Loading