From dd39b87fff1f786efdee586e323bf249a60bd243 Mon Sep 17 00:00:00 2001 From: Ricardo Colombo Oliveira Date: Mon, 23 Nov 2026 16:24:51 +0100 Subject: [PATCH 1/3] docs(dotnet): Show how to turn off logs from Logging.AddSentry() The v7 migration guide only showed SetBeforeSendLog(_ => null) for dropping logs. Apps that call SentrySdk.Init and Logging.AddSentry() can set the Sentry provider's level to None instead, which keeps errors and breadcrumbs, works from configuration and creates no logs. Refs getsentry/sentry-dotnet#5988 Co-Authored-By: Claude Opus 5.5 --- ...ablelogs-is-removed-from-sentryoptions.mdx | 2 +- .../logging-integrations-send-logs.mdx | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx b/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx index 5772557c4f264..ba407c65067a9 100644 --- a/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx +++ b/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx @@ -13,7 +13,7 @@ Version 7 removes `EnableLogs` from `SentryOptions`, the core options of the SDK 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). +- **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. To turn off the logs from `Logging.AddSentry()` and keep its errors and breadcrumbs, set `LogLevel` to `None` under `Logging:Sentry`. 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. diff --git a/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx b/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx index ba6bf246ed2b8..e32fa1fd88e8b 100644 --- a/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx +++ b/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx @@ -32,7 +32,9 @@ SentrySdk.Init(options => }); ``` -To drop every log and keep sending errors and breadcrumbs, return `null`: +To drop every log and keep sending errors and breadcrumbs, return `null` from `SetBeforeSendLog`, or turn off the `Sentry` logging provider. The callback works for every integration and for `SentrySdk.Logger`. The provider setting works only for `Logging.AddSentry()`, but you can set it in configuration, and the SDK creates no logs for the entries it filters. + +With the callback, return `null`: ```csharp {filename:Program.cs} SentrySdk.Init(options => @@ -42,7 +44,7 @@ SentrySdk.Init(options => }); ``` -In apps that call `UseSentry`, set the same callback on its options. The callback applies to every log, including logs from `SentrySdk.Logger` and from the `ILogger` integration. +In apps that call `UseSentry`, set the same callback on its options: ```csharp {filename:Program.cs} var builder = WebApplication.CreateBuilder(args); @@ -53,4 +55,29 @@ builder.UseSentry(options => }); ``` +To turn off the `Sentry` logging provider, set its level to `None`. If your app reads the `Logging` section from configuration, as `WebApplication.CreateBuilder` and `Host.CreateApplicationBuilder` do, set it in `appsettings.json`: + +```json {filename:appsettings.json} +{ + "Logging": { + "Sentry": { + "LogLevel": { + "Default": "None" + } + } + } +} +``` + +Otherwise, add the same rule when you add the integration: + +```csharp {filename:Program.cs} +using var loggerFactory = LoggerFactory.Create(builder => +{ + builder.AddSentry(); + builder.Services.Configure(options => + options.Rules.Add(new LoggerFilterRule("Sentry", null, LogLevel.None, null))); +}); +``` + See [Logs](/platforms/dotnet/logs/) for more about filtering logs. From d9c9e51456fa3d5011487055919c83542bfb066c Mon Sep 17 00:00:00 2001 From: Ricardo Colombo Oliveira Date: Mon, 23 Nov 2026 17:37:12 +0100 Subject: [PATCH 2/3] docs(dotnet): Say what the Sentry provider alias filters The Logs page said Sentry's provider has the alias Sentry, but not what that means for filters, so Logging:Sentry:LogLevel read as if Sentry were a category. The note now says a LogLevel section under Logging:Sentry applies only to Sentry's logs and its keys are categories. Refs getsentry/sentry-dotnet#5988 Co-Authored-By: Claude Opus 5.5 --- platform-includes/logs/options/dotnet.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/logs/options/dotnet.mdx b/platform-includes/logs/options/dotnet.mdx index 8801a6d9f9e33..481c82ab541c8 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -18,7 +18,7 @@ In earlier versions, `EnableLogs` was an option on `SentryOptions`, and the Seri #### Configure Microsoft.Extensions.Logging Filters -Sentry's `Microsoft.Extensions.Logging` provider defines the alias `Sentry`. +Sentry's `Microsoft.Extensions.Logging` provider defines the alias `Sentry`, so you can use `Sentry` as the provider name in your filters. A `LogLevel` section under `Logging:Sentry` applies only to the logs Sentry sends. Its keys are categories, the same as in the top-level `LogLevel` section. Logs emitted through `ILogger` are sent to Sentry according to your configured provider/category filters and log levels. From 36464d72f6686330a95ae8966541e04a15629243 Mon Sep 17 00:00:00 2001 From: Ricardo Colombo Oliveira Date: Tue, 24 Nov 2026 09:57:24 +0100 Subject: [PATCH 3/3] docs(dotnet): Name the full key and each integration's logs switch "Set LogLevel to None under Logging:Sentry" reads as "Sentry": { "LogLevel": "None" }, which Microsoft.Extensions.Logging ignores. Name the full Logging:Sentry:LogLevel:Default key instead. The Sentry alias is on every ILogger logs provider, including the ones UseSentry adds, so drop "works only for Logging.AddSentry()". List NLog's minimumLogLevel as its switch, and say that the Serilog sink and the log4net appender have none yet, so they need SetBeforeSendLog. Link to the filters section on the Extensions.Logging guide, because the plain .NET Logs page doesn't show it. Co-Authored-By: Claude Opus 5.5 --- .../enablelogs-is-removed-from-sentryoptions.mdx | 2 +- .../dotnet-v7/logging-integrations-send-logs.mdx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx b/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx index ba407c65067a9..ea37d0c88f393 100644 --- a/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx +++ b/includes/migration/dotnet-v7/enablelogs-is-removed-from-sentryoptions.mdx @@ -13,7 +13,7 @@ Version 7 removes `EnableLogs` from `SentryOptions`, the core options of the SDK 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. To turn off the logs from `Logging.AddSentry()` and keep its errors and breadcrumbs, set `LogLevel` to `None` under `Logging:Sentry`. See [Logging Integrations Send Logs](#logging-integrations-send-logs). +- **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. To turn off the logs from `Logging.AddSentry()` and keep its errors and breadcrumbs, set `Logging:Sentry:LogLevel:Default` to `None`. 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. diff --git a/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx b/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx index e32fa1fd88e8b..f3f52ac537c45 100644 --- a/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx +++ b/includes/migration/dotnet-v7/logging-integrations-send-logs.mdx @@ -32,7 +32,12 @@ SentrySdk.Init(options => }); ``` -To drop every log and keep sending errors and breadcrumbs, return `null` from `SetBeforeSendLog`, or turn off the `Sentry` logging provider. The callback works for every integration and for `SentrySdk.Logger`. The provider setting works only for `Logging.AddSentry()`, but you can set it in configuration, and the SDK creates no logs for the entries it filters. +To drop every log and keep sending errors and breadcrumbs, return `null` from `SetBeforeSendLog`. The callback works for every integration and for `SentrySdk.Logger`. Some integrations also have their own switch, which you can set in configuration and which stops the SDK from creating those logs at all: + +- For `ILogger`, turn off the `Sentry` logging provider, as shown below. +- For NLog, set [`minimumLogLevel`](/platforms/dotnet/guides/nlog/logs/#minimumloglevel) to `Off` on the target. + +The Serilog sink and the log4net appender have no such switch, so use the callback for those. With the callback, return `null`: @@ -80,4 +85,4 @@ using var loggerFactory = LoggerFactory.Create(builder => }); ``` -See [Logs](/platforms/dotnet/logs/) for more about filtering logs. +See [Logs](/platforms/dotnet/logs/) for more about filtering logs, and [Configure Microsoft.Extensions.Logging Filters](/platforms/dotnet/guides/extensions-logging/logs/#configure-microsoftextensionslogging-filters) for more about the `Sentry` provider.