You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logging-Configuration is not applied to Sentry-Logger-Provider #4539
Indeed ... the intended behavior for Structured Logs is to be configurable through "standard" Logging-Configuration, like appsettings.json.
For Breadcrumbs and Events we have explicit Sentry-Options:
Should Sentry.Extensions.Logging and all inheriting SDKs (like Sentry.AspNetCore) have the same behavor, or is it intended that there is different behavior?
If the behavior should be identical, should it include Configuration, or only consider SentryLoggingOptions?
Structured Logs
Should the behavior be different or identical for Breadcrumbs+Events and Structured Logs?
In other words, do we only want Logging-Configuration, like appsettings.json (originally intended)
or should we only have a MinimumLogLevel in SentryLoggingOptions
or both, where the Logging-Configuration is applied first, and then the SentryLoggingOptions are evaluated
Just MinimumLogLevel it's not enough for sure. It's my biggest pain right now. The logs in sentry have a lot of noisy logs. I have diferent level for specific categories, some warning, some information or error. Using opentelemetry and otel collector standard logging configuration give me option filter that before send to anywhere else. But right now sentry is just collecting everything.
I'm afraid the Runtime Switch option wouldn't be "clean" either ... but only half-working and half-breaking.
I do now prefer to ship this change in 6.0.0 (and upcoming pre-releases), due to the inherently behavior-breaking change.
.NET 10 GA is now roughly one month away.
However, now having learned more about the nitty-gritty of Microsoft.Extensions.Logging in ASP.NET Core, there may be a temporary workaround for your scenario in the meantime:
// after invoking `UseSentry` on the ASP.NET Core Web-App-Builderbuilder.Logging.Services.Configure<LoggerFilterOptions>(static(LoggerFilterOptionsoptions)=>{LoggerFilterRulerule=options.Rules.Single(static(LoggerFilterRulerule)=>rule.ProviderName=="Sentry.AspNetCore.SentryAspNetCoreStructuredLoggerProvider");boolremoved=options.Rules.Remove(rule);if(!removed){thrownewInvalidOperationException("Rule for Sentry's Structured Logs not found.");}rule=newLoggerFilterRule(rule.ProviderName,"Sentry.ISentryClient",LogLevel.None,null);options.Rules.Add(rule);rule=newLoggerFilterRule(rule.ProviderName,"Sentry.AspNetCore.SentryMiddleware",LogLevel.None,null);options.Rules.Add(rule);});// before invoking `Build` on the ASP.NET Core Web-App-Builder
This should get you through [5.16.0, 6.0.0), until we ship the actually intended behavior across all Microsoft.Extensions.Logging integrations in 6.0.0 together with the .NET 10 release.
Warning
This is unsupported and dangerous (accessing internal implementation details).
This will stop working with 6.0.0 (and pre-releases), and may then actually cause unintended / undefined behavior.
@wondertalik, would you mind pinging me if that works for you.
I'll ping you once we got the intended behavior fixed in an upcoming 6.0.0-preview.* that we'd love to get feedback on.
@Flash0ver I have tried your suggested temporary workaround and can confirm the expected results. For our use case this works great since it prevents Sentry from being spammed by great amounts of database query logs.
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.Single[TSource](IEnumerable`1source, Func`2predicate)
at Program.<>c.<<Main>$>b__0_1(LoggerFilterOptionsoptions)in/Users/admin/Works/Caropticom/Training/AzureContainerApps/src/HttpApi/Program.cs:line 24
at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(Stringname,TOptionsoptions)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(Stringname)
at Microsoft.Extensions.Options.OptionsMonitor`1.<>c.<Get>b__10_0(Stringname, IOptionsFactory`1factory)
at Microsoft.Extensions.Options.OptionsCache`1.<>c__DisplayClass3_1`1.<GetOrAdd>b__2()
at System.Lazy`1.ViaFactory(LazyThreadSafetyModemode)
2. .net 10 is GA, when do you plan to release 6.0?
Should be within the next couple of weeks. There's a 6.0.0-rc.1 release available already... although we did discover an issue in this related to tracing on ASP.NET Core - so will be at least one more RC release.
Activity
linear commentedon Sep 18, 2025
NET-456 Logging-Configuration is not applied to Sentry-Logger-Provider
Flash0ver commentedon Sep 24, 2025
TIL, when adding a
LoggerFilterRule(viaAddFilter) we opt-out of the "Minimum-Log-Level-From-Configuration" rule:sentry-dotnet/src/Sentry.Extensions.Logging/LoggingBuilderExtensions.cs
Line 60 in 6ea6bf4
But just adding a Category and Level, just as via
appsettings.json, does not replace the default rule:sentry-dotnet/src/Sentry.AspNetCore/SentryWebHostBuilderExtensions.cs
Lines 98 to 100 in 6ea6bf4
Flash0ver commentedon Sep 24, 2025
Indeed ... the intended behavior for Structured Logs is to be configurable through "standard" Logging-Configuration, like
appsettings.json.For Breadcrumbs and Events we have explicit Sentry-Options:
Sentry.Extensions.Logging.SentryLoggingOptions.MinimumBreadcrumbLevelSentry.Extensions.Logging.SentryLoggingOptions.MinimumEventLevelBut we got different behavior in
Sentry.Extensions.LoggingandSentry.AspNetCoreMicrosoft.Extensions.Loggingis ignored and only the options are evaluated.For
Sentry.Extensions.Logging, see:sentry-dotnet/src/Sentry.Extensions.Logging/LoggingBuilderExtensions.cs
Lines 57 to 60 in 6ea6bf4
Questions:
Breadcrumbs + Events
Sentry.Extensions.Loggingand all inheriting SDKs (likeSentry.AspNetCore) have the same behavor, or is it intended that there is different behavior?SentryLoggingOptions?Structured Logs
appsettings.json(originally intended)MinimumLogLevelinSentryLoggingOptionsSentryLoggingOptionsare evaluatedwondertalik commentedon Sep 24, 2025
Hi, there.
Just
MinimumLogLevelit's not enough for sure. It's my biggest pain right now. The logs in sentry have a lot of noisy logs. I have diferent level for specific categories, somewarning, someinformationorerror. Using opentelemetry and otel collector standard logging configuration give me option filter that before send to anywhere else. But right now sentry is just collecting everything.Thanks for your work, btw.
23 remaining items
Flash0ver commentedon Oct 7, 2025
I'm afraid the Runtime Switch option wouldn't be "clean" either ... but only half-working and half-breaking.
I do now prefer to ship this change in
6.0.0(and upcoming pre-releases), due to the inherently behavior-breaking change..NET 10 GA is now roughly one month away.
However, now having learned more about the nitty-gritty of
Microsoft.Extensions.Loggingin ASP.NET Core, there may be a temporary workaround for your scenario in the meantime:{ "Logging": { "LogLevel": { }, "SentryLogs": { "LogLevel": { "Default": "Warning", "Program": "Error", "MyCategory": "Critical" } } } }This should get you through
[5.16.0, 6.0.0), until we ship the actually intended behavior across allMicrosoft.Extensions.Loggingintegrations in6.0.0together with the .NET 10 release.Warning
This is unsupported and dangerous (accessing internal implementation details).
This will stop working with
6.0.0(and pre-releases), and may then actually cause unintended / undefined behavior.@wondertalik, would you mind pinging me if that works for you.
I'll ping you once we got the intended behavior fixed in an upcoming
6.0.0-preview.*that we'd love to get feedback on.TimSalomons commentedon Oct 30, 2025
@Flash0ver I have tried your suggested temporary workaround and can confirm the expected results. For our use case this works great since it prevents Sentry from being spammed by great amounts of database query logs.
wondertalik commentedon Nov 14, 2025
@Flash0ver hi there
Updates, i tried solution above and i got an exception.
Example, https://github.com/wondertalik/azure-container-apps/blob/b0123cbb6e92fc0f588946c9a615555d41459593/src/HttpApi/Program.cs#L21
I use this repo as example in ahother issue
jamescrosswell commentedon Nov 18, 2025
Should be within the next couple of weeks. There's a 6.0.0-rc.1 release available already... although we did discover an issue in this related to tracing on ASP.NET Core - so will be at least one more RC release.