Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/platforms/dotnet/common/migration/v6-to-v7/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ The [Interactive 7.x Migration Guide](./interactive/) lets you check off complet

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

### Category Log Levels No Longer Filter Breadcrumbs and Events

<Include name="migration/dotnet-v7/category-log-levels-no-longer-filter-breadcrumbs-and-events" />

### Logging Frameworks No Longer Close Sentry

<Include name="migration/dotnet-v7/logging-frameworks-no-longer-close-sentry" />
Expand Down
10 changes: 1 addition & 9 deletions includes/dotnet-v7-migration-overview.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
<Alert level="warning" title="Release candidate">

There is no stable 7.0 release of the Sentry SDK for .NET yet. Until 7.0.0 ships, use the latest 7.0.0 release candidate from [NuGet](https://www.nuget.org/packages/Sentry/#versions-body-tab) 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).

The release candidate's `net11.0` builds depend on the .NET 11 versions of `Microsoft.Extensions.Http`, `Microsoft.Extensions.Logging.Configuration` and `Microsoft.Extensions.Configuration.Binder`. `Sentry.AspNetCore.Blazor.WebAssembly` also depends on the .NET 11 version of `Microsoft.AspNetCore.Components.WebAssembly`. A .NET 11 app that directly references an older version of one of these packages, such as 10.0.x, fails to restore with error NU1605. The error message shows the version the Sentry package needs. Update the reference to that version, or remove it.

</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. See [Generic Host](/platforms/dotnet/guides/extensions-hosting/).
- **`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`](/platforms/dotnet/guides/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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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:
In version 6.12.1 and earlier, `UseSentry` was only available on the web host:

```csharp {filename:Program.cs}
var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -51,4 +51,4 @@ public static class Extensions
}
```

When `UseSentry` from `Sentry.Extensions.Hosting` runs in an ASP.NET Core app, the SDK logs a warning through `ILogger` when the host starts.
When `UseSentry` from `Sentry.Extensions.Hosting` runs in an ASP.NET Core app, the SDK logs a warning through `ILogger` when the host starts. For the same call in a MAUI app, see [.NET Aspire Service Defaults](/platforms/dotnet/guides/extensions-hosting/#net-aspire-service-defaults) in the Generic Host guide.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
id: category-log-levels-no-longer-filter-breadcrumbs-and-events
title: "Category Log Levels No Longer Filter Breadcrumbs and Events"
phase: verify
category: behavior
severity: behavior-change
frameworks: all
platformCategory: all
order: 15
---

In version 7, category entries under `Logging:Sentry:LogLevel` filter only the `ILogger` entries that Sentry sends as logs. In version 6.12.1 and earlier, these entries also filtered breadcrumbs and events from the same category. The `Default` entry is unchanged: it has always applied only to logs.

For example, this entry keeps `Microsoft.EntityFrameworkCore` entries below `Error` out of the logs:

```json {filename:appsettings.json}
{
"Logging": {
"Sentry": {
"LogLevel": {
"Microsoft.EntityFrameworkCore": "Error"
}
}
}
}
```

In 6.x, it kept them out of the breadcrumbs too. In 7.x, they show up as breadcrumbs.

To keep filtering breadcrumbs and events by category, add a log entry filter where you initialize Sentry. The SDK drops an entry from breadcrumbs and events when the filter returns `true`:

```csharp {filename:Program.cs}
using Sentry.Extensions.Logging;

var builder = WebApplication.CreateBuilder(args);
builder.UseSentry(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.AddLogEntryFilter((category, level, eventId, exception) =>
category.StartsWith("Microsoft.EntityFrameworkCore") && level < LogLevel.Error);
});
```

If the app calls `Logging.AddSentry()` after `SentrySdk.Init`, call `AddLogEntryFilter` on the options of `Logging.AddSentry()` instead.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ builder.Services.AddHostedService<Worker>();
builder.Build().Run();
```

`UseSentry` also registers `IHub` for dependency injection and sets the environment from the host environment. It works on `IHostApplicationBuilder` types such as `Host.CreateApplicationBuilder` on .NET 8 and later. It also works on `IHostBuilder` types such as `Host.CreateDefaultBuilder` on every target, including .NET Framework.
`UseSentry` also registers `IHub` for dependency injection and sets the environment from the host environment. It works on `IHostApplicationBuilder` types such as `Host.CreateApplicationBuilder` on .NET 8 and later. It also works on `IHostBuilder` types such as `Host.CreateDefaultBuilder` on every target, including .NET Framework. The [Generic Host](/platforms/dotnet/guides/extensions-hosting/) guide shows the full setup.

If the app calls `builder.Logging.ClearProviders()`, call `UseSentry` after it. `ClearProviders` removes every logger provider registered before it, including Sentry's, and the app then sends no errors from `ILogger`. If the app has to clear providers after `UseSentry`, call `builder.Logging.AddSentry()` after `ClearProviders` to add Sentry's providers back. Skip that if Serilog, NLog or log4net already sends the app's `ILogger` entries to Sentry, because each entry would then arrive twice.

Expand Down
13 changes: 7 additions & 6 deletions includes/migration/dotnet-v7/other-removed-and-internal-apis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ order: 130

Version 7 removes a few APIs that most apps don't use, makes others internal and reorders some parameters. Update any code that uses them:

| API | Migration |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `Envelope.FromEvent`, `Envelope.FromFeedback`, `Envelope.FromTransaction` | The `IDiagnosticLogger` parameter moves to the end. Reorder the arguments or pass them by name. |
| `options.Native.EnableAppHangTrackingV2` on iOS and Mac Catalyst | Use `options.Native.EnableAppHangTracking`. App hang tracking V2 is already the default. |
| `options.Native.AddInAppExclude(string)` on iOS and Mac Catalyst | Remove the call. It had no effect. |
| `SentryOptions.ScopeObserver`, `SentryOptions.EnableScopeSync`, `SentryOptions.CrashedLastRun` | These are internal now, because only the SDK's native integrations set them. Remove references to them. |
| API | Migration |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Envelope.FromEvent`, `Envelope.FromFeedback`, `Envelope.FromTransaction` | The `IDiagnosticLogger` parameter moves to the end. Reorder the arguments or pass them by name. |
| `options.Native.EnableAppHangTrackingV2` on iOS and Mac Catalyst | Use `options.Native.EnableAppHangTracking`. App hang tracking V2 is already the default. |
| `options.Native.AddInAppExclude(string)` on iOS and Mac Catalyst | Remove the call. It had no effect. |
| `SentryOptions.ScopeObserver`, `SentryOptions.EnableScopeSync`, `SentryOptions.CrashedLastRun` | These are internal now, because only the SDK's native integrations set them. Remove references to them. |
| `GetInternalSentryOptions()` on `ISentryClient` and `IHub` | Use `GetDiagnosticLogger()` on `IHub`, in the `Sentry.Extensibility` namespace, to get the SDK's diagnostic logger. The removed method was only meant for Sentry's own integrations. |

The SDK ignores an `EnableScopeSync` key in the `Sentry` section of `appsettings.json`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Each package keeps the .NET Standard and .NET Framework targets it had in 6.x. `
| Mac Catalyst | 15.0 | 17.0 |
| iOS | 15.0 | 15.0 |

The [Supported Versions](/platforms/dotnet/guides/maui/#supported-versions) section of the MAUI guide also lists the minimum Windows version.

Move each mobile or MAUI project to .NET 10 or .NET 11 before you update the Sentry packages:

```xml {filename:MyApp.csproj}
Expand All @@ -48,3 +50,5 @@ An app that targets .NET 11 also needs the higher platform minimums:
If a project still targets `net9.0-android`, `net9.0-ios` or `net9.0-maccatalyst`, NuGet gives it the plain `net9.0` build of `Sentry` 7. That build has no native SDK, so the app loses native crash reporting. Stay on 6.x until you move the app to .NET 10.

A .NET 9 MAUI project can't use `Sentry.Maui` 7 at all. The package has no .NET 9 target, so NuGet fails the restore with error NU1202.

The `net11.0` builds of the Sentry packages depend on the .NET 11 versions of `Microsoft.Extensions.Http`, `Microsoft.Extensions.Logging.Configuration` and `Microsoft.Extensions.Configuration.Binder`. `Sentry.AspNetCore.Blazor.WebAssembly` also depends on the .NET 11 version of `Microsoft.AspNetCore.Components.WebAssembly`. A .NET 11 app that directly references an older version of one of these packages, such as 10.0.x, fails to restore with error NU1605. The error message shows the version the Sentry package needs. Update the reference to that version, or remove it.
Loading