Repository navigation
Description
Description
WebAssemblyHostBuilder.UseSentry(o => ...) configures SentryBlazorOptions, but the two Microsoft.Extensions.Logging providers it registers never see those options.
LoggingBuilderExtensions.AddSentry<TOptions> registers SentryLoggerProvider and SentryStructuredLoggerProvider by type. Their public constructors take IOptions<SentryLoggingOptions>. In a Blazor app, dependency injection resolves that as a separate SentryLoggingOptions with default values, not the SentryBlazorOptions the app configured.
The SDK initializes the Hub from SentryBlazorOptions, so the DSN, sampling and other core options work. The problem is limited to the options that the logger providers read:
| Option | Effect in Blazor today |
|---|---|
MinimumEventLevel |
Ignored; always Error |
MinimumBreadcrumbLevel |
Ignored; always Information |
AddLogEntryFilter(...) |
Ignored; the SDK still sends filtered entries as events and breadcrumbs |
ConfigureScope(...) |
Callbacks never run |
EnableLogs (6.x) |
Ignored; always false, so the SDK never sends ILogger entries as Sentry logs |
Sentry options under Logging:Sentry in configuration |
Ignored, for the same reason |
Because the SDK ignores the filters, this fails open. It still sends log entries that users filter out, for example ones that contain personal data.
The bug has been present since the Blazor WebAssembly integration shipped in 4.8.0 (#3386). It affects no other integration. ASP.NET Core and MAUI register their own provider subclasses, which ask for their own options types. Blazor Server, gRPC and Google Cloud Functions use the ASP.NET Core integration. The plain ILoggingBuilder.AddSentry() path stores and reads SentryLoggingOptions, so its types match.
Reproduction
A unit test reproduces the bug by calling AddSentry<TOptions> the same way Blazor does. Its options type derives from SentryLoggingOptions. The test sets MinimumEventLevel = Warning, adds a log entry filter for the category Sensitive, and adds a ConfigureScope callback.
LogWarningin the categoryAppcaptures no event. It should capture one.LogErrorin the filtered categorySensitivecaptures one event. It should capture none.- The
ConfigureScopecallback never runs. It should run once.
Proposed fix
In AddSentry<TOptions>, build both providers from IOptions<TOptions>. IOptions<T> is covariant, so the existing constructors accept it unchanged. A factory registration keeps the providers' runtime types, so AddFilter<SentryLoggerProvider> rules and Logging:Sentry provider configuration still apply.
With that change, the warning captures one event, the filtered category captures none, and the scope callback runs once. A LogLevel.None filter rule for SentryLoggerProvider still blocks events.
After the fix, options that Blazor users already set start taking effect. For example, on 6.x, EnableLogs = true starts sending ILogger entries as Sentry logs.
Activity
linear-code commentedon Sep 29, 2026
NET-830
fix(blazor): logging options set in UseSentry now take effect (getsen…