From 761099ff32f85f6735895aa567f54799cd3a2d13 Mon Sep 17 00:00:00 2001 From: KyleTryon Date: Tue, 28 Apr 2026 11:43:02 -0400 Subject: [PATCH 01/11] docs(dotnet): Enhance logging documentation for Microsoft.Extensions.Logging integration - Added detailed instructions for configuring logging filters with Microsoft.Extensions.Logging. - Clarified the behavior of `EnableLogs` and its interaction with Sentry's logging capabilities. - Included code examples for both JSON configuration and programmatic filter setup. - Updated initialization instructions to specify that `EnableLogs` must be set to true for logging to function correctly. --- platform-includes/logs/options/dotnet.mdx | 52 ++++++++++++++++++++++- platform-includes/logs/setup/dotnet.mdx | 7 ++- platform-includes/logs/usage/dotnet.mdx | 5 ++- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/platform-includes/logs/options/dotnet.mdx b/platform-includes/logs/options/dotnet.mdx index 7fab5cabe44f6..dd90e58cf3cbb 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -12,9 +12,59 @@ Set to `true` in order to enable the logging integration via the `ILogger + + +#### Configure Microsoft.Extensions.Logging Filters + +In apps that use `Microsoft.Extensions.Logging`, setting `EnableLogs = true` enables Sentry's `Microsoft.Extensions.Logging` integration. + +Logs emitted through `ILogger` are sent to Sentry according to your configured provider/category filters and log levels. + +Use standard `Microsoft.Extensions.Logging` filtering to reduce noisy categories or disable the Sentry provider: + +```json {filename:appsettings.json} +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + }, + "Sentry": { + "LogLevel": { + "Default": "None" + } + } + } +} +``` + +Setting `Logging:Sentry:LogLevel:Default` to `None` disables logs sent through the `Microsoft.Extensions.Logging` provider, while `EnableLogs = true` keeps the `SentrySdk.Logger` APIs available. + +Example with `EnableLogs = true` and `Logging:Sentry:LogLevel:Default = None`: + +```csharp +logger.LogInformation("Will not be sent to Sentry through Microsoft.Extensions.Logging"); +SentrySdk.Logger.LogInfo("Still sent via SentrySdk.Logger"); +``` + +You can also configure filters in code: + +```csharp +// Default minimum level for all categories +builder.Logging.AddFilter(null, LogLevel.Warning); +// Override for a specific category +builder.Logging.AddFilter("MyApp.Namespace", LogLevel.Information); +``` + +For framework-specific setup details, see [Microsoft.Extensions.Logging for .NET](https://docs.sentry.io/platforms/dotnet/guides/extensions-logging/logs/). + +For background on provider/category filtering, see [Logging in C# and .NET](https://learn.microsoft.com/dotnet/core/extensions/logging/overview#configure-logging). + + + #### SetBeforeSendLog -To filter logs, or update them before they are sent to Sentry, you can use the `SetBeforeSendLog(Func)` option. +To filter logs or update them before they are sent to Sentry, you can use the `SetBeforeSendLog(Func)` option. ```csharp options => diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index dc614c6db66d9..f485d7b2d2869 100644 --- a/platform-includes/logs/setup/dotnet.mdx +++ b/platform-includes/logs/setup/dotnet.mdx @@ -1,4 +1,9 @@ -To enable logging, you need to initialize the SDK with the `EnableLogs` option set to `true`. +Set `EnableLogs` to `true` when initializing the SDK to send logs to Sentry. This enables: + +- The `SentrySdk.Logger` APIs +- Supported logging integrations for your platform, such as `Microsoft.Extensions.Logging` and Serilog + +It does _not_ capture `Console.WriteLine()` output. diff --git a/platform-includes/logs/usage/dotnet.mdx b/platform-includes/logs/usage/dotnet.mdx index 954010a4df43a..5bfded261ff9e 100644 --- a/platform-includes/logs/usage/dotnet.mdx +++ b/platform-includes/logs/usage/dotnet.mdx @@ -15,8 +15,9 @@ SentrySdk.Logger.LogError("A {0} log message", "formatted"); -Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using instances of the [ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger-1) interface, -resolved through _.NET dependency injection_. +Once the feature is enabled and the SDK is initialized, you can send logs using instances of the [ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger-1) interface, resolved through .NET dependency injection. + +Sentry respects your existing `Microsoft.Extensions.Logging` category/provider configuration. The `LoggerExtensions` extension methods expose various overloads that you can use to log messages at six different log levels automatically mapped to Sentry's severity: From fffb60551be616326d7dbf918c3417849de6372f Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:41:18 -0400 Subject: [PATCH 02/11] Update platform-includes/logs/usage/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/logs/usage/dotnet.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/logs/usage/dotnet.mdx b/platform-includes/logs/usage/dotnet.mdx index 5bfded261ff9e..ba5e186ffec08 100644 --- a/platform-includes/logs/usage/dotnet.mdx +++ b/platform-includes/logs/usage/dotnet.mdx @@ -15,7 +15,7 @@ SentrySdk.Logger.LogError("A {0} log message", "formatted"); -Once the feature is enabled and the SDK is initialized, you can send logs using instances of the [ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger-1) interface, resolved through .NET dependency injection. +Once the feature is enabled and the SDK is initialized, you can send logs using instances of the [ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger-1) interface, resolved through [.NET dependency injection](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection/overview). Sentry respects your existing `Microsoft.Extensions.Logging` category/provider configuration. From 694ced0a464f319bcfbb52e716ea3827c36750f9 Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:41:34 -0400 Subject: [PATCH 03/11] Update platform-includes/logs/usage/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/logs/usage/dotnet.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/logs/usage/dotnet.mdx b/platform-includes/logs/usage/dotnet.mdx index ba5e186ffec08..19ae34be91bcc 100644 --- a/platform-includes/logs/usage/dotnet.mdx +++ b/platform-includes/logs/usage/dotnet.mdx @@ -17,7 +17,7 @@ SentrySdk.Logger.LogError("A {0} log message", "formatted"); Once the feature is enabled and the SDK is initialized, you can send logs using instances of the [ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger-1) interface, resolved through [.NET dependency injection](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection/overview). -Sentry respects your existing `Microsoft.Extensions.Logging` category/provider configuration. +Sentry respects your existing `Microsoft.Extensions.Logging` provider/category configuration. The `LoggerExtensions` extension methods expose various overloads that you can use to log messages at six different log levels automatically mapped to Sentry's severity: From 17bea487661367180bd39152334ce92396aeb286 Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:42:09 -0400 Subject: [PATCH 04/11] Update platform-includes/logs/setup/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/logs/setup/dotnet.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index f485d7b2d2869..93a3e61f7d858 100644 --- a/platform-includes/logs/setup/dotnet.mdx +++ b/platform-includes/logs/setup/dotnet.mdx @@ -16,6 +16,9 @@ SentrySdk.Init(options => }); ``` + +This enables the `SentrySdk.Logger` APIs. + From bfc60f9d5cde267e7a922a360db6bd98fba725c4 Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:42:28 -0400 Subject: [PATCH 05/11] Update platform-includes/logs/setup/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/logs/setup/dotnet.mdx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index 93a3e61f7d858..8dd79d7c125d0 100644 --- a/platform-includes/logs/setup/dotnet.mdx +++ b/platform-includes/logs/setup/dotnet.mdx @@ -1,9 +1,4 @@ -Set `EnableLogs` to `true` when initializing the SDK to send logs to Sentry. This enables: - -- The `SentrySdk.Logger` APIs -- Supported logging integrations for your platform, such as `Microsoft.Extensions.Logging` and Serilog - -It does _not_ capture `Console.WriteLine()` output. +To enable logging, you need to initialize the SDK with the `EnableLogs` option set to `true`. From 612e8f6073b76bd4e5454c7da31f7fc0b5880c2b Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:42:37 -0400 Subject: [PATCH 06/11] Update platform-includes/logs/setup/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/logs/setup/dotnet.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index 8dd79d7c125d0..0924498075876 100644 --- a/platform-includes/logs/setup/dotnet.mdx +++ b/platform-includes/logs/setup/dotnet.mdx @@ -27,6 +27,9 @@ This enables the `SentrySdk.Logger` APIs. }); ``` + +This enables the `SentrySdk.Logger` APIs, as well as the `Microsoft.Extensions.Logging` integration. + From 371d965198e4c22b056cdb2fa58025cb0d0b4ea3 Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:42:46 -0400 Subject: [PATCH 07/11] Update platform-includes/logs/setup/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/logs/setup/dotnet.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index 0924498075876..d1b4937716233 100644 --- a/platform-includes/logs/setup/dotnet.mdx +++ b/platform-includes/logs/setup/dotnet.mdx @@ -69,4 +69,8 @@ This enables the `SentrySdk.Logger` APIs, as well as the `Microsoft.Extensions.L }); ``` + + +It does _not_ capture the `Console.WriteLine()` standard output stream. + From 8f039a15444a1949989f7e53213f99a321cbb1cc Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:42:59 -0400 Subject: [PATCH 08/11] Update platform-includes/logs/options/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- 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 dd90e58cf3cbb..861d82372b742 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -12,7 +12,7 @@ Set to `true` in order to enable the logging integration via the `ILogger - + #### Configure Microsoft.Extensions.Logging Filters From f771aa53c59fe3d7d276e2b3d7836a04f0d7b9fa Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:43:07 -0400 Subject: [PATCH 09/11] Update platform-includes/logs/options/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/logs/options/dotnet.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/platform-includes/logs/options/dotnet.mdx b/platform-includes/logs/options/dotnet.mdx index 861d82372b742..6862cd8334e90 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -17,6 +17,7 @@ Set to `true` in order to enable the logging integration via the `Log`/`Logger` #### Configure Microsoft.Extensions.Logging Filters In apps that use `Microsoft.Extensions.Logging`, setting `EnableLogs = true` enables Sentry's `Microsoft.Extensions.Logging` integration. +Sentry's provider defines the alias `Sentry`. Logs emitted through `ILogger` are sent to Sentry according to your configured provider/category filters and log levels. From 90cb332d7e20ccb150247b7d81b675f17364c330 Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 16:43:21 -0400 Subject: [PATCH 10/11] Update platform-includes/logs/options/dotnet.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- 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 6862cd8334e90..53826bbf6df9f 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -39,7 +39,7 @@ Use standard `Microsoft.Extensions.Logging` filtering to reduce noisy categories } ``` -Setting `Logging:Sentry:LogLevel:Default` to `None` disables logs sent through the `Microsoft.Extensions.Logging` provider, while `EnableLogs = true` keeps the `SentrySdk.Logger` APIs available. +Setting `Logging:Sentry:LogLevel:Default` to `None` disables logs sent through the `Microsoft.Extensions.Logging` provider for all categories, while `EnableLogs = true` keeps the `SentrySdk.Logger` APIs available. Example with `EnableLogs = true` and `Logging:Sentry:LogLevel:Default = None`: From c0d771949d711dce4b0b4234caf59b45b209d67a Mon Sep 17 00:00:00 2001 From: "Kyle a.k.a. TechSquidTV" Date: Wed, 29 Apr 2026 17:05:39 -0400 Subject: [PATCH 11/11] Apply suggestion from @KyleTryon --- platform-includes/logs/options/dotnet.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/platform-includes/logs/options/dotnet.mdx b/platform-includes/logs/options/dotnet.mdx index 53826bbf6df9f..7d20f79800a62 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -57,7 +57,6 @@ builder.Logging.AddFilter(null, LogLevel.Warning); builder.Logging.AddFilter("MyApp.Namespace", LogLevel.Information); ``` -For framework-specific setup details, see [Microsoft.Extensions.Logging for .NET](https://docs.sentry.io/platforms/dotnet/guides/extensions-logging/logs/). For background on provider/category filtering, see [Logging in C# and .NET](https://learn.microsoft.com/dotnet/core/extensions/logging/overview#configure-logging).