Skip to content

Commit 11fe02b

Browse files
committed
fix(logs): Logging Filter
1 parent 7624baa commit 11fe02b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/Sentry.AspNetCore/SentryWebHostBuilderExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public static IWebHostBuilder UseSentry(
100100
LogLevel.None);
101101
_ = logging.AddFilter<SentryAspNetCoreStructuredLoggerProvider>(static (string? categoryName, LogLevel logLevel) =>
102102
{
103-
return categoryName is null || !categoryName.StartsWith("Sentry");
103+
return categoryName is null
104+
|| (categoryName != "Sentry.ISentryClient" && categoryName != "Sentry.AspNetCore.SentryMiddleware");
104105
});
105106

106107
var sentryBuilder = logging.Services.AddSentry();

src/Sentry.Extensions.Logging/LoggingBuilderExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ internal static ILoggingBuilder AddSentry<TOptions>(
6363
// Filtering of logs is handled in SentryStructuredLogger, using SentryOptions.MinimumLogLevel
6464
builder.AddFilter<SentryStructuredLoggerProvider>(static (string? categoryName, LogLevel logLevel) =>
6565
{
66-
return categoryName is null || !categoryName.StartsWith("Sentry");
66+
return categoryName is null
67+
|| categoryName != "Sentry.ISentryClient";
6768
});
6869

6970
return builder;

src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public static MauiAppBuilder UseSentry(this MauiAppBuilder builder,
5656
services.AddSingleton<IConfigureOptions<SentryMauiOptions>, SentryMauiOptionsSetup>();
5757
services.AddSingleton<Disposer>();
5858

59+
builder.Logging.AddFilter<SentryMauiStructuredLoggerProvider>(static (string? categoryName, LogLevel logLevel) =>
60+
{
61+
return categoryName is null
62+
|| categoryName != "Sentry.ISentryClient";
63+
});
64+
5965
services.AddSingleton<IMauiElementEventBinder, MauiButtonEventsBinder>();
6066
services.AddSingleton<IMauiElementEventBinder, MauiImageButtonEventsBinder>();
6167
services.AddSingleton<IMauiElementEventBinder, MauiGestureRecognizerEventsBinder>();

0 commit comments

Comments
 (0)