-
-
Notifications
You must be signed in to change notification settings - Fork 227
fix(logs): minimum Log-Level for Structured Logs #4700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4700 +/- ##
==========================================
+ Coverage 73.85% 73.91% +0.05%
==========================================
Files 485 485
Lines 17689 17686 -3
Branches 3497 3494 -3
==========================================
+ Hits 13065 13072 +7
+ Misses 3762 3756 -6
+ Partials 862 858 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@sentry review |
jamescrosswell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - nice work @Flash0ver !
I suggested a couple of convenience changes, but happy to merge whenever you are.
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
| services.AddSingleton<IConfigureOptions<SentryMauiOptions>, SentryMauiOptionsSetup>(); | ||
| services.AddSingleton<Disposer>(); | ||
|
|
||
| builder.Logging.AddFilter<SentryMauiStructuredLoggerProvider>(static (string? categoryName, LogLevel logLevel) => | ||
| { | ||
| return categoryName is null | ||
| || categoryName != "Sentry.ISentryClient"; | ||
| }); | ||
| // Add a delegate rule in order to ignore Configuration like "appsettings.json" and "appsettings.{HostEnvironment}.json" | ||
| builder.Logging.AddFilter<SentryMauiLoggerProvider>(_ => true); | ||
| // Add non-delegate rules in order to respect Configuration like "appsettings.json" and "appsettings.{HostEnvironment}.json" | ||
| builder.Logging.AddFilter<SentryMauiStructuredLoggerProvider>("Sentry.ISentryClient", LogLevel.None); | ||
|
|
||
| // Add default event binders | ||
| services.AddSingleton<IMauiElementEventBinder, MauiButtonEventsBinder>(); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it via Sentry.Samples.Maui ... and it works end-to-end.
Fixes #4539
Fixes #4734
Summary
Previously, the Logging-Configuration was inconsistent between SDKs (M.E.L, ASP.NET Core, MAUI, Google-Cloud-Functions):
This changeset is normalizing the applied Logging-Filter-Rules across all integrations:
Logging-Configuration (i.e.
Logging:LogLevel:DefaultandLogging:Sentry:LogLevel:Defaultvia e.g.appsettings.json) is now respected for Structured Logs, but now ignored for Breadcrumbs and Events, since we have existingMinimumBreadcrumbLevelandMinimumEventLevel, as well asAddLogEntryFilterextension methods for filtering Breadcrumbs and Events.New
Sentry.Google.Cloud.Functionsnow supports Structured LogsEnableLogs = trueChanged
SentryLoggingOptions.ExperimentalLogging.MinimumLogLevelfor Structured-Logs"Sentry"logging provider nameappsettings.json) now only applies to Structured Loggingappsettings.json) no longer applies to BreadcrumbsSentryLoggingOptions.MinimumBreadcrumbLevelandSentryLoggingOptionsExtensions.AddLogEntryFilterappsettings.json) no longer applies to EventsSentryLoggingOptions.MinimumEventLevelandSentryLoggingOptionsExtensions.AddLogEntryFilterILoggerProviderandIConfigureOptionsinternalLoggerFilterRules are correctly setsentry-docsSentryStructuredLoggerProvider(and derived for ASP.NET Core and MAUI) now have[ProviderAlias("Sentry")]appsettings.jsonconfiguration for Structured LogsTesting
Microsoft.Extensions.Logging.LoggerFilterRule)SentryLoggerProvider(and derived) is NOT configurable viaappsettings.json(for Breadcrumbs and Events)LoggerFilterRule.FilterSentryStructuredLoggerProvider(and derived) IS configurable viaappsettings.json(via the"Sentry"logging provider name)LoggerFilterRule.FilterbeingnullILoggerProviderfor Breadcrumbs/Events and theILoggerProviderfor Structured LogsSamples
appsettings.jsonof these samples to show how to configure Structured Logs, in contrast to Breadcrumbs and EventsSentry.Samples.AspNetCore.BasicSentry.Samples.GenericHostSentry.Samples.Google.Cloud.FunctionsImportant
This functionality relies on a quirk/feature of
Microsoft.Extensions.Logging.LoggerFilterRule. When a filter delegate is configured, filtering via configuration bindings are ignored and only the filtering delegate is applied. When not using a filter delegate, log filtering from configuration bindings does get applied.