From d3f45a8eada35bb64f51c8dd3ada73f16fb162b8 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 11 Nov 2026 16:29:40 +1300 Subject: [PATCH 1/7] feat(nlog)!: add minLevel to AddSentry so logs below it aren't sent AddSentry() added a rule for every level, and every entry reaching the Sentry target is sent as a structured log. Apps that route ILogger through NLog therefore sent every Trace and Debug entry as a log. The new optional minLevel parameter sets the rule's lower bound; it defaults to Trace, so existing behaviour is unchanged. The ASP.NET Core NLog sample now uses AddSentry(minLevel: ...) instead of building the rule by hand. Closes #5909 Co-Authored-By: Claude Opus 5.5 --- .../Sentry.Samples.AspNetCore.NLog/Program.cs | 23 ++++++++----------- src/Sentry.NLog/ConfigurationExtensions.cs | 10 ++++++-- ...iApprovalTests.Run.DotNet10_0.verified.txt | 2 +- ...iApprovalTests.Run.DotNet11_0.verified.txt | 2 +- ...piApprovalTests.Run.DotNet8_0.verified.txt | 2 +- ...piApprovalTests.Run.DotNet9_0.verified.txt | 2 +- .../ApiApprovalTests.Run.Net4_8.verified.txt | 2 +- .../ConfigurationExtensionsTest.cs | 18 +++++++++++++++ 8 files changed, 41 insertions(+), 20 deletions(-) diff --git a/samples/Sentry.Samples.AspNetCore.NLog/Program.cs b/samples/Sentry.Samples.AspNetCore.NLog/Program.cs index ff0cf7adeb..3af90566ef 100644 --- a/samples/Sentry.Samples.AspNetCore.NLog/Program.cs +++ b/samples/Sentry.Samples.AspNetCore.NLog/Program.cs @@ -2,7 +2,6 @@ using NLog.Config; using NLog.Targets; using NLog.Web; -using Sentry.NLog; // UseSentry below only starts Sentry once the app is running. Initializing it here as well captures crashes during // startup, until UseSentry takes over: https://docs.sentry.io/platforms/dotnet/guides/nlog/#capturing-startup-crashes @@ -15,20 +14,18 @@ #endif }); -// Configure NLog to send logs to Sentry. This only adds the Sentry target: it does not initialize Sentry. -var sentryTarget = new SentryTarget(new SentryNLogOptions -{ - // Warn and higher are added as breadcrumbs (default is Info) - MinimumBreadcrumbLevel = NLog.LogLevel.Warn, - // Error and higher are sent as events (default is Error) - MinimumEventLevel = NLog.LogLevel.Error, -}); - var nlogConfig = new LoggingConfiguration(); nlogConfig.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, new ColoredConsoleTarget("console")); -// Every entry that reaches the Sentry target is sent as a structured log, so this rule sets the minimum level for logs. -// Info and higher are sent as logs. Breadcrumbs and events can only use entries that pass this rule. -nlogConfig.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, sentryTarget); +// Configure NLog to send logs to Sentry. This only adds the Sentry target: it does not initialize Sentry. +nlogConfig.AddSentry(options => + { + // Warn and higher are added as breadcrumbs (default is Info) + options.MinimumBreadcrumbLevel = NLog.LogLevel.Warn; + // Error and higher are sent as events (default is Error) + options.MinimumEventLevel = NLog.LogLevel.Error; + }, + // Info and higher are sent as logs. Breadcrumbs and events can only use entries at this level or higher. + minLevel: NLog.LogLevel.Info); LogManager.Configuration = nlogConfig; try diff --git a/src/Sentry.NLog/ConfigurationExtensions.cs b/src/Sentry.NLog/ConfigurationExtensions.cs index 5fb8e6a3ad..299c0d03de 100644 --- a/src/Sentry.NLog/ConfigurationExtensions.cs +++ b/src/Sentry.NLog/ConfigurationExtensions.cs @@ -59,11 +59,17 @@ public static LoggingConfiguration AddSentry( /// The NLog configuration. /// An optional action for configuring the Sentry target options. /// The name to give the new target. + /// + /// The minimum level of entries that reach the target. Every entry that reaches it is sent as a log, so this sets + /// the minimum level for logs, and breadcrumbs and events can only use entries at this level or higher. + /// Defaults to , which sends every entry. + /// /// The configuration. public static LoggingConfiguration AddSentry( this LoggingConfiguration configuration, Action? optionsConfig = null, - string targetName = DefaultTargetName) + string targetName = DefaultTargetName, + LogLevel? minLevel = null) { // Not to throw on code that ignores nullability warnings. if (configuration.IsNull()) @@ -89,7 +95,7 @@ public static LoggingConfiguration AddSentry( configuration.AddTarget(targetName, target); - configuration.AddRuleForAllLevels(targetName); + configuration.AddRule(minLevel ?? LogLevel.Trace, LogLevel.Fatal, targetName); return configuration; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index 898643e61a..4f50412f72 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt index 898643e61a..4f50412f72 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 898643e61a..4f50412f72 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 898643e61a..4f50412f72 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 898643e61a..4f50412f72 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } diff --git a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs index 4a1efcb3a9..fcec03b26b 100644 --- a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs +++ b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs @@ -24,6 +24,24 @@ public void AddSentry_TargetName_TargetNamed() Assert.Equal("custom", actual.AllTargets[0].Name); } + [Fact] + public void AddSentry_NoMinLevel_RuleCoversAllLevels() + { + var actual = new LoggingConfiguration().AddSentry(); + + var rule = Assert.Single(actual.LoggingRules); + Assert.Equal(LogLevel.AllLoggingLevels, rule.Levels); + } + + [Fact] + public void AddSentry_MinLevel_RuleStartsAtMinLevel() + { + var actual = new LoggingConfiguration().AddSentry(minLevel: LogLevel.Info); + + var rule = Assert.Single(actual.LoggingRules); + Assert.Equal(new[] { LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Fatal }, rule.Levels); + } + [Fact] public void AddTag_SetToTarget() { From cf61833240916a6fd7524b732fd0b117ff718e13 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 11 Nov 2026 16:43:01 +1300 Subject: [PATCH 2/7] feat(nlog)!: default AddSentry's minLevel to Info Trace and Debug entries no longer reach the Sentry target unless minLevel says so, matching Microsoft.Extensions.Logging's usual Information default. The console sample lowers MinimumBreadcrumbLevel to Debug, so it now passes minLevel: Debug to keep those breadcrumbs. Co-Authored-By: Claude Opus 5.5 --- samples/Sentry.Samples.AspNetCore.NLog/Program.cs | 4 +--- samples/Sentry.Samples.NLog/Program.cs | 3 ++- src/Sentry.NLog/ConfigurationExtensions.cs | 4 ++-- test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/samples/Sentry.Samples.AspNetCore.NLog/Program.cs b/samples/Sentry.Samples.AspNetCore.NLog/Program.cs index 3af90566ef..94a85ba08e 100644 --- a/samples/Sentry.Samples.AspNetCore.NLog/Program.cs +++ b/samples/Sentry.Samples.AspNetCore.NLog/Program.cs @@ -23,9 +23,7 @@ options.MinimumBreadcrumbLevel = NLog.LogLevel.Warn; // Error and higher are sent as events (default is Error) options.MinimumEventLevel = NLog.LogLevel.Error; - }, - // Info and higher are sent as logs. Breadcrumbs and events can only use entries at this level or higher. - minLevel: NLog.LogLevel.Info); + }); LogManager.Configuration = nlogConfig; try diff --git a/samples/Sentry.Samples.NLog/Program.cs b/samples/Sentry.Samples.NLog/Program.cs index c2561f69ab..786bd9af2f 100644 --- a/samples/Sentry.Samples.NLog/Program.cs +++ b/samples/Sentry.Samples.NLog/Program.cs @@ -136,7 +136,8 @@ private static void UsingCodeConfiguration() }; options.AddTag("logger", "${logger}"); // Send the logger name as a tag - }); + }, + minLevel: LogLevel.Debug); // Debug and higher reach the Sentry target and are sent as logs (default is Info) config.AddTarget(new DebuggerTarget("debugger")); diff --git a/src/Sentry.NLog/ConfigurationExtensions.cs b/src/Sentry.NLog/ConfigurationExtensions.cs index 299c0d03de..3bfd848c2a 100644 --- a/src/Sentry.NLog/ConfigurationExtensions.cs +++ b/src/Sentry.NLog/ConfigurationExtensions.cs @@ -62,7 +62,7 @@ public static LoggingConfiguration AddSentry( /// /// The minimum level of entries that reach the target. Every entry that reaches it is sent as a log, so this sets /// the minimum level for logs, and breadcrumbs and events can only use entries at this level or higher. - /// Defaults to , which sends every entry. + /// Defaults to . /// /// The configuration. public static LoggingConfiguration AddSentry( @@ -95,7 +95,7 @@ public static LoggingConfiguration AddSentry( configuration.AddTarget(targetName, target); - configuration.AddRule(minLevel ?? LogLevel.Trace, LogLevel.Fatal, targetName); + configuration.AddRule(minLevel ?? LogLevel.Info, LogLevel.Fatal, targetName); return configuration; } diff --git a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs index fcec03b26b..deec7c7eb9 100644 --- a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs +++ b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs @@ -25,21 +25,21 @@ public void AddSentry_TargetName_TargetNamed() } [Fact] - public void AddSentry_NoMinLevel_RuleCoversAllLevels() + public void AddSentry_NoMinLevel_RuleStartsAtInfo() { var actual = new LoggingConfiguration().AddSentry(); var rule = Assert.Single(actual.LoggingRules); - Assert.Equal(LogLevel.AllLoggingLevels, rule.Levels); + Assert.Equal(new[] { LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Fatal }, rule.Levels); } [Fact] public void AddSentry_MinLevel_RuleStartsAtMinLevel() { - var actual = new LoggingConfiguration().AddSentry(minLevel: LogLevel.Info); + var actual = new LoggingConfiguration().AddSentry(minLevel: LogLevel.Trace); var rule = Assert.Single(actual.LoggingRules); - Assert.Equal(new[] { LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Fatal }, rule.Levels); + Assert.Equal(LogLevel.AllLoggingLevels, rule.Levels); } [Fact] From e2767d0c7d1dae22eb30bb90c9a96018370f68f7 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 11 Nov 2026 16:51:44 +1300 Subject: [PATCH 3/7] feat(nlog)!: replace AddSentry's minLevel with SentryNLogOptions.MinimumLogLevel A rule bound also limits breadcrumbs and events, so Trace breadcrumbs couldn't be kept alongside Info-and-up logs. MinimumLogLevel sits next to MinimumEventLevel and MinimumBreadcrumbLevel, filters only structured logs, defaults to Info, and can be set from XML (minimumLogLevel="Debug"). AddSentry goes back to a rule for every level, with its 6.x signature. The EnableLogs messages now point at MinimumLogLevel=Off rather than SetBeforeSendLog. Co-Authored-By: Claude Opus 5.5 --- .../Sentry.Samples.AspNetCore.NLog/Program.cs | 4 +- samples/Sentry.Samples.NLog/NLog.config | 3 +- samples/Sentry.Samples.NLog/Program.cs | 4 +- src/Sentry.NLog/ConfigurationExtensions.cs | 10 +---- src/Sentry.NLog/SentryNLogOptions.cs | 5 +++ src/Sentry.NLog/SentryTarget.cs | 28 ++++++++---- ...iApprovalTests.Run.DotNet10_0.verified.txt | 9 ++-- ...iApprovalTests.Run.DotNet11_0.verified.txt | 9 ++-- ...piApprovalTests.Run.DotNet8_0.verified.txt | 9 ++-- ...piApprovalTests.Run.DotNet9_0.verified.txt | 9 ++-- .../ApiApprovalTests.Run.Net4_8.verified.txt | 9 ++-- .../ConfigurationExtensionsTest.cs | 18 -------- .../SentryNLogOptionsTests.cs | 7 +++ .../SentryTargetTests.Structured.cs | 44 +++++++++++++++++++ test/Sentry.NLog.Tests/SentryTargetTests.cs | 3 +- 15 files changed, 111 insertions(+), 60 deletions(-) diff --git a/samples/Sentry.Samples.AspNetCore.NLog/Program.cs b/samples/Sentry.Samples.AspNetCore.NLog/Program.cs index 94a85ba08e..f871820cb7 100644 --- a/samples/Sentry.Samples.AspNetCore.NLog/Program.cs +++ b/samples/Sentry.Samples.AspNetCore.NLog/Program.cs @@ -23,6 +23,8 @@ options.MinimumBreadcrumbLevel = NLog.LogLevel.Warn; // Error and higher are sent as events (default is Error) options.MinimumEventLevel = NLog.LogLevel.Error; + // Info and higher are sent as logs (default is Info) + options.MinimumLogLevel = NLog.LogLevel.Info; }); LogManager.Configuration = nlogConfig; @@ -49,7 +51,7 @@ app.MapGet("/", (ILogger logger) => { - logger.LogDebug("Below the Sentry rule's minimum level, so not sent to Sentry"); + logger.LogDebug("Below every Sentry minimum level, so not sent to Sentry"); logger.LogInformation("Sent as a log"); logger.LogWarning("Sent as a log and added as a breadcrumb"); logger.LogError("Sent as a log and as an event, which includes the breadcrumb above"); diff --git a/samples/Sentry.Samples.NLog/NLog.config b/samples/Sentry.Samples.NLog/NLog.config index 9e512f40e1..388996132b 100644 --- a/samples/Sentry.Samples.NLog/NLog.config +++ b/samples/Sentry.Samples.NLog/NLog.config @@ -19,7 +19,8 @@ ignoreEventsWithNoException="False" includeEventDataOnBreadcrumbs="False" includeEventPropertiesAsTags="True" - minimumEventLevel="Error"> + minimumEventLevel="Error" + minimumLogLevel="Info"> diff --git a/samples/Sentry.Samples.NLog/Program.cs b/samples/Sentry.Samples.NLog/Program.cs index 786bd9af2f..fff6a48411 100644 --- a/samples/Sentry.Samples.NLog/Program.cs +++ b/samples/Sentry.Samples.NLog/Program.cs @@ -119,6 +119,7 @@ private static void UsingCodeConfiguration() options.MinimumBreadcrumbLevel = LogLevel.Debug; // Debug and higher are stored as breadcrumbs (default is Info) options.MinimumEventLevel = LogLevel.Error; // Error and higher are sent as events (default is Error) + options.MinimumLogLevel = LogLevel.Info; // Info and higher are sent as logs (default is Info) options.IncludeEventDataOnBreadcrumbs = true; // Optionally include event properties with breadcrumbs @@ -136,8 +137,7 @@ private static void UsingCodeConfiguration() }; options.AddTag("logger", "${logger}"); // Send the logger name as a tag - }, - minLevel: LogLevel.Debug); // Debug and higher reach the Sentry target and are sent as logs (default is Info) + }); config.AddTarget(new DebuggerTarget("debugger")); diff --git a/src/Sentry.NLog/ConfigurationExtensions.cs b/src/Sentry.NLog/ConfigurationExtensions.cs index 3bfd848c2a..5fb8e6a3ad 100644 --- a/src/Sentry.NLog/ConfigurationExtensions.cs +++ b/src/Sentry.NLog/ConfigurationExtensions.cs @@ -59,17 +59,11 @@ public static LoggingConfiguration AddSentry( /// The NLog configuration. /// An optional action for configuring the Sentry target options. /// The name to give the new target. - /// - /// The minimum level of entries that reach the target. Every entry that reaches it is sent as a log, so this sets - /// the minimum level for logs, and breadcrumbs and events can only use entries at this level or higher. - /// Defaults to . - /// /// The configuration. public static LoggingConfiguration AddSentry( this LoggingConfiguration configuration, Action? optionsConfig = null, - string targetName = DefaultTargetName, - LogLevel? minLevel = null) + string targetName = DefaultTargetName) { // Not to throw on code that ignores nullability warnings. if (configuration.IsNull()) @@ -95,7 +89,7 @@ public static LoggingConfiguration AddSentry( configuration.AddTarget(targetName, target); - configuration.AddRule(minLevel ?? LogLevel.Info, LogLevel.Fatal, targetName); + configuration.AddRuleForAllLevels(targetName); return configuration; } diff --git a/src/Sentry.NLog/SentryNLogOptions.cs b/src/Sentry.NLog/SentryNLogOptions.cs index 99ec14a79b..d2eaa87abd 100644 --- a/src/Sentry.NLog/SentryNLogOptions.cs +++ b/src/Sentry.NLog/SentryNLogOptions.cs @@ -20,6 +20,11 @@ public class SentryNLogOptions /// public LogLevel? MinimumBreadcrumbLevel { get; set; } = LogLevel.Info; + /// + /// Minimum log level to be sent to Sentry as a structured log. Defaults to . + /// + public LogLevel? MinimumLogLevel { get; set; } = LogLevel.Info; + /// /// Set this to to ignore log messages that don't contain an exception. /// diff --git a/src/Sentry.NLog/SentryTarget.cs b/src/Sentry.NLog/SentryTarget.cs index 29aa61f297..42b6937435 100644 --- a/src/Sentry.NLog/SentryTarget.cs +++ b/src/Sentry.NLog/SentryTarget.cs @@ -137,22 +137,29 @@ public string MinimumBreadcrumbLevel set => Options.MinimumBreadcrumbLevel = LogLevel.FromString(value); } + /// + /// Minimum log level to be sent to Sentry as a structured log. Defaults to . + /// + public string MinimumLogLevel + { + get => Options.MinimumLogLevel?.ToString() ?? LogLevel.Off.ToString(); + set => Options.MinimumLogLevel = LogLevel.FromString(value); + } + internal const string ObsoleteEnableLogs = - "The Sentry target always sends logs. This option is ignored and will be removed in a future major version. " + - "To drop logs, use SetBeforeSendLog on the options passed to SentrySdk.Init and return null."; + "This option is ignored and will be removed in a future major version. " + + "To stop the Sentry target sending logs, set MinimumLogLevel to Off."; internal const string EnableLogsFalseIgnored = - "The Sentry target always sends logs, so enableLogs=\"false\" no longer turns them off. " + - "Remove enableLogs from the target configuration. " + - "To drop logs, use SetBeforeSendLog on the options passed to SentrySdk.Init and return null."; + "enableLogs=\"false\" no longer turns logs off. Remove enableLogs from the target configuration, " + + "and set minimumLogLevel=\"Off\" instead."; /// - /// Logs are always generated and sent. + /// No longer has any effect. Use instead. /// /// - /// This option no longer has any effect. The getter always returns . + /// The getter always returns . /// Setting it to only writes a warning to standard error. - /// To filter or drop logs, use and return . /// [Obsolete(ObsoleteEnableLogs)] public bool EnableLogs @@ -253,6 +260,9 @@ protected override void FlushAsync(AsyncContinuation asyncContinuation) /// as a breadcrumb to the Sentry Sdk. /// /// + /// If the event level is >= the , the event is sent as a structured log. + /// + /// /// If sentry is not enabled, this is a No-op. /// /// @@ -337,7 +347,7 @@ private void InnerWrite(LogEventInfo logEvent) } var sentryOptions = hub.GetSentryOptions(); - if (sentryOptions is not null) + if (sentryOptions is not null && logEvent.Level >= Options.MinimumLogLevel) { try { diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index 4f50412f72..c158c37320 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } @@ -28,6 +28,7 @@ namespace Sentry.NLog public NLog.Layouts.Layout? Layout { get; set; } public NLog.LogLevel? MinimumBreadcrumbLevel { get; set; } public NLog.LogLevel? MinimumEventLevel { get; set; } + public NLog.LogLevel? MinimumLogLevel { get; set; } [NLog.Config.NLogConfigurationIgnoreProperty] public System.Collections.Generic.IList Tags { get; } [NLog.Config.NLogConfigurationIgnoreProperty] @@ -54,9 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("The Sentry target always sends logs. This option is ignored and will be removed i" + - "n a future major version. To drop logs, use SetBeforeSendLog on the options pass" + - "ed to SentrySdk.Init and return null.")] + [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + + " Sentry target sending logs, set MinimumLogLevel to Off.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } @@ -65,6 +65,7 @@ namespace Sentry.NLog public bool InitializeSdk { get; set; } public string MinimumBreadcrumbLevel { get; set; } public string MinimumEventLevel { get; set; } + public string MinimumLogLevel { get; set; } public Sentry.NLog.SentryNLogOptions Options { get; } [NLog.Config.ArrayParameter(typeof(NLog.Targets.TargetPropertyWithContext), "tag")] public System.Collections.Generic.IList Tags { get; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt index 4f50412f72..c158c37320 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } @@ -28,6 +28,7 @@ namespace Sentry.NLog public NLog.Layouts.Layout? Layout { get; set; } public NLog.LogLevel? MinimumBreadcrumbLevel { get; set; } public NLog.LogLevel? MinimumEventLevel { get; set; } + public NLog.LogLevel? MinimumLogLevel { get; set; } [NLog.Config.NLogConfigurationIgnoreProperty] public System.Collections.Generic.IList Tags { get; } [NLog.Config.NLogConfigurationIgnoreProperty] @@ -54,9 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("The Sentry target always sends logs. This option is ignored and will be removed i" + - "n a future major version. To drop logs, use SetBeforeSendLog on the options pass" + - "ed to SentrySdk.Init and return null.")] + [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + + " Sentry target sending logs, set MinimumLogLevel to Off.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } @@ -65,6 +65,7 @@ namespace Sentry.NLog public bool InitializeSdk { get; set; } public string MinimumBreadcrumbLevel { get; set; } public string MinimumEventLevel { get; set; } + public string MinimumLogLevel { get; set; } public Sentry.NLog.SentryNLogOptions Options { get; } [NLog.Config.ArrayParameter(typeof(NLog.Targets.TargetPropertyWithContext), "tag")] public System.Collections.Generic.IList Tags { get; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 4f50412f72..c158c37320 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } @@ -28,6 +28,7 @@ namespace Sentry.NLog public NLog.Layouts.Layout? Layout { get; set; } public NLog.LogLevel? MinimumBreadcrumbLevel { get; set; } public NLog.LogLevel? MinimumEventLevel { get; set; } + public NLog.LogLevel? MinimumLogLevel { get; set; } [NLog.Config.NLogConfigurationIgnoreProperty] public System.Collections.Generic.IList Tags { get; } [NLog.Config.NLogConfigurationIgnoreProperty] @@ -54,9 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("The Sentry target always sends logs. This option is ignored and will be removed i" + - "n a future major version. To drop logs, use SetBeforeSendLog on the options pass" + - "ed to SentrySdk.Init and return null.")] + [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + + " Sentry target sending logs, set MinimumLogLevel to Off.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } @@ -65,6 +65,7 @@ namespace Sentry.NLog public bool InitializeSdk { get; set; } public string MinimumBreadcrumbLevel { get; set; } public string MinimumEventLevel { get; set; } + public string MinimumLogLevel { get; set; } public Sentry.NLog.SentryNLogOptions Options { get; } [NLog.Config.ArrayParameter(typeof(NLog.Targets.TargetPropertyWithContext), "tag")] public System.Collections.Generic.IList Tags { get; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 4f50412f72..c158c37320 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } @@ -28,6 +28,7 @@ namespace Sentry.NLog public NLog.Layouts.Layout? Layout { get; set; } public NLog.LogLevel? MinimumBreadcrumbLevel { get; set; } public NLog.LogLevel? MinimumEventLevel { get; set; } + public NLog.LogLevel? MinimumLogLevel { get; set; } [NLog.Config.NLogConfigurationIgnoreProperty] public System.Collections.Generic.IList Tags { get; } [NLog.Config.NLogConfigurationIgnoreProperty] @@ -54,9 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("The Sentry target always sends logs. This option is ignored and will be removed i" + - "n a future major version. To drop logs, use SetBeforeSendLog on the options pass" + - "ed to SentrySdk.Init and return null.")] + [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + + " Sentry target sending logs, set MinimumLogLevel to Off.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } @@ -65,6 +65,7 @@ namespace Sentry.NLog public bool InitializeSdk { get; set; } public string MinimumBreadcrumbLevel { get; set; } public string MinimumEventLevel { get; set; } + public string MinimumLogLevel { get; set; } public Sentry.NLog.SentryNLogOptions Options { get; } [NLog.Config.ArrayParameter(typeof(NLog.Targets.TargetPropertyWithContext), "tag")] public System.Collections.Generic.IList Tags { get; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 4f50412f72..c158c37320 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -3,9 +3,9 @@ namespace NLog { public static class ConfigurationExtensions { + public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry") { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, System.Action? optionsConfig = null) { } - public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, System.Action? optionsConfig = null, string targetName = "sentry", NLog.LogLevel? minLevel = null) { } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public static NLog.Config.LoggingConfiguration AddSentry(this NLog.Config.LoggingConfiguration configuration, string? dsn, string targetName, System.Action? optionsConfig = null) { } public static void AddTag(this Sentry.NLog.SentryNLogOptions options, string name, NLog.Layouts.Layout layout) { } @@ -28,6 +28,7 @@ namespace Sentry.NLog public NLog.Layouts.Layout? Layout { get; set; } public NLog.LogLevel? MinimumBreadcrumbLevel { get; set; } public NLog.LogLevel? MinimumEventLevel { get; set; } + public NLog.LogLevel? MinimumLogLevel { get; set; } [NLog.Config.NLogConfigurationIgnoreProperty] public System.Collections.Generic.IList Tags { get; } [NLog.Config.NLogConfigurationIgnoreProperty] @@ -54,9 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("The Sentry target always sends logs. This option is ignored and will be removed i" + - "n a future major version. To drop logs, use SetBeforeSendLog on the options pass" + - "ed to SentrySdk.Init and return null.")] + [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + + " Sentry target sending logs, set MinimumLogLevel to Off.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } @@ -65,6 +65,7 @@ namespace Sentry.NLog public bool InitializeSdk { get; set; } public string MinimumBreadcrumbLevel { get; set; } public string MinimumEventLevel { get; set; } + public string MinimumLogLevel { get; set; } public Sentry.NLog.SentryNLogOptions Options { get; } [NLog.Config.ArrayParameter(typeof(NLog.Targets.TargetPropertyWithContext), "tag")] public System.Collections.Generic.IList Tags { get; } diff --git a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs index deec7c7eb9..4a1efcb3a9 100644 --- a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs +++ b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs @@ -24,24 +24,6 @@ public void AddSentry_TargetName_TargetNamed() Assert.Equal("custom", actual.AllTargets[0].Name); } - [Fact] - public void AddSentry_NoMinLevel_RuleStartsAtInfo() - { - var actual = new LoggingConfiguration().AddSentry(); - - var rule = Assert.Single(actual.LoggingRules); - Assert.Equal(new[] { LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Fatal }, rule.Levels); - } - - [Fact] - public void AddSentry_MinLevel_RuleStartsAtMinLevel() - { - var actual = new LoggingConfiguration().AddSentry(minLevel: LogLevel.Trace); - - var rule = Assert.Single(actual.LoggingRules); - Assert.Equal(LogLevel.AllLoggingLevels, rule.Levels); - } - [Fact] public void AddTag_SetToTarget() { diff --git a/test/Sentry.NLog.Tests/SentryNLogOptionsTests.cs b/test/Sentry.NLog.Tests/SentryNLogOptionsTests.cs index 7b13df9a80..4ab91f7b03 100644 --- a/test/Sentry.NLog.Tests/SentryNLogOptionsTests.cs +++ b/test/Sentry.NLog.Tests/SentryNLogOptionsTests.cs @@ -15,4 +15,11 @@ public void Ctor_MinimumEventLevel_Error() var options = new SentryNLogOptions(); Assert.Equal(LogLevel.Error, options.MinimumEventLevel); } + + [Fact] + public void Ctor_MinimumLogLevel_Info() + { + var options = new SentryNLogOptions(); + Assert.Equal(LogLevel.Info, options.MinimumLogLevel); + } } diff --git a/test/Sentry.NLog.Tests/SentryTargetTests.Structured.cs b/test/Sentry.NLog.Tests/SentryTargetTests.Structured.cs index 1318e01ef7..3454cf8f41 100644 --- a/test/Sentry.NLog.Tests/SentryTargetTests.Structured.cs +++ b/test/Sentry.NLog.Tests/SentryTargetTests.Structured.cs @@ -40,6 +40,7 @@ public void Write_StructuredLogging_LogLevel(LogLevel level, SentryLogLevel expe { InMemorySentryStructuredLogger capturer = new(); _fixture.Hub.Logger.Returns(capturer); + _fixture.Options.MinimumLogLevel = LogLevel.Trace; var logger = _fixture.GetLogger(); @@ -48,6 +49,49 @@ public void Write_StructuredLogging_LogLevel(LogLevel level, SentryLogLevel expe capturer.Logs.Should().ContainSingle().Which.Level.Should().Be(expected); } + public static TheoryData MinimumLogLevelData => new() + { + { null, ["Info message"] }, + { "Debug", ["Debug message", "Info message"] }, + { "Warn", [] }, + { "Off", [] }, + }; + + [Theory] + [MemberData(nameof(MinimumLogLevelData))] + public void Write_StructuredLogging_MinimumLogLevel(string? minimumLogLevel, string[] expectedMessages) + { + InMemorySentryStructuredLogger capturer = new(); + _fixture.Hub.Logger.Returns(capturer); + if (minimumLogLevel is not null) + { + _fixture.Options.MinimumLogLevel = LogLevel.FromString(minimumLogLevel); + } + + var logger = _fixture.GetLogger(); + + logger.Debug("Debug message"); + logger.Info("Info message"); + + capturer.Logs.Select(log => log.Message).Should().Equal(expectedMessages); + } + + [Fact] + public void Write_BelowMinimumLogLevel_StillAddsBreadcrumb() + { + InMemorySentryStructuredLogger capturer = new(); + _fixture.Hub.Logger.Returns(capturer); + _fixture.Options.MinimumBreadcrumbLevel = LogLevel.Trace; + _fixture.Options.MinimumLogLevel = LogLevel.Info; + + var logger = _fixture.GetLogger(); + + logger.Trace(DefaultMessage); + + capturer.Logs.Should().BeEmpty(); + _fixture.Scope.Breadcrumbs.Should().ContainSingle().Which.Message.Should().Be(DefaultMessage); + } + [Theory] [InlineData(true)] [InlineData(false)] diff --git a/test/Sentry.NLog.Tests/SentryTargetTests.cs b/test/Sentry.NLog.Tests/SentryTargetTests.cs index 5c92edb16d..b3afbc3622 100644 --- a/test/Sentry.NLog.Tests/SentryTargetTests.cs +++ b/test/Sentry.NLog.Tests/SentryTargetTests.cs @@ -75,7 +75,7 @@ public void Can_configure_from_xml_file() - + True @@ -91,6 +91,7 @@ public void Can_configure_from_xml_file() var t = logFactory.Configuration.FindTargetByName("sentry") as SentryTarget; Assert.NotNull(t); Assert.Equal(LogLevel.Warn, t.Options.MinimumEventLevel); + Assert.Equal(LogLevel.Debug, t.Options.MinimumLogLevel); Assert.True(t.Options.IgnoreEventsWithNoException); Assert.True(t.Options.IncludeEventPropertiesAsTags); } From eff9f9f3788e0a84a9161591fdb2bc5b6266e08b Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 11 Nov 2026 17:20:31 +1300 Subject: [PATCH 4/7] test(nlog): cover the MinimumLogLevel target property getter Co-Authored-By: Claude Opus 5.5 --- test/Sentry.NLog.Tests/SentryTargetTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Sentry.NLog.Tests/SentryTargetTests.cs b/test/Sentry.NLog.Tests/SentryTargetTests.cs index b3afbc3622..ce20bf057b 100644 --- a/test/Sentry.NLog.Tests/SentryTargetTests.cs +++ b/test/Sentry.NLog.Tests/SentryTargetTests.cs @@ -96,6 +96,18 @@ public void Can_configure_from_xml_file() Assert.True(t.Options.IncludeEventPropertiesAsTags); } + [Theory] + [InlineData("Debug", "Debug")] + [InlineData(null, "Off")] + public void MinimumLogLevel_Get_ReturnsOptionsLevel(string optionsLevel, string expected) + { + _fixture.Options.MinimumLogLevel = optionsLevel is null ? null : LogLevel.FromString(optionsLevel); + + var target = (SentryTarget)_fixture.GetTarget(); + + Assert.Equal(expected, target.MinimumLogLevel); + } + [Fact] public void Can_configure_user_from_xml_file() { From 4bd3d974c1f8a6176d2187cd2f3a896647fc5f08 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 11 Nov 2026 22:00:06 +1300 Subject: [PATCH 5/7] perf(nlog): start AddSentry's rule at the lowest minimum level AddSentry added a rule for every level, so entries below all three minimum levels still reached the target and were dropped there. The rule now starts at the lowest of MinimumEventLevel, MinimumBreadcrumbLevel and MinimumLogLevel (Info by default). Co-Authored-By: Claude Opus 5.5 --- src/Sentry.NLog/ConfigurationExtensions.cs | 10 ++++- .../ConfigurationExtensionsTest.cs | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/Sentry.NLog/ConfigurationExtensions.cs b/src/Sentry.NLog/ConfigurationExtensions.cs index 5fb8e6a3ad..6a37750140 100644 --- a/src/Sentry.NLog/ConfigurationExtensions.cs +++ b/src/Sentry.NLog/ConfigurationExtensions.cs @@ -55,6 +55,8 @@ public static LoggingConfiguration AddSentry( /// /// This doesn't initialise Sentry. Initialise Sentry separately, using SentrySdk.Init or another Sentry /// integration (such as ASP.NET Core or MAUI). + /// The rule it adds starts at the lowest of the target's minimum levels. Lowering one of them after calling this + /// method doesn't let lower entries through. /// /// The NLog configuration. /// An optional action for configuring the Sentry target options. @@ -89,11 +91,17 @@ public static LoggingConfiguration AddSentry( configuration.AddTarget(targetName, target); - configuration.AddRuleForAllLevels(targetName); + configuration.AddRule(LowestMinimumLevel(options), LogLevel.Fatal, targetName); return configuration; } + private static LogLevel LowestMinimumLevel(SentryNLogOptions options) + { + LogLevel?[] levels = [options.MinimumEventLevel, options.MinimumBreadcrumbLevel, options.MinimumLogLevel]; + return levels.OfType().DefaultIfEmpty(LogLevel.Off).Min()!; + } + /// /// Add additional tags that will be sent with every message. /// diff --git a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs index 4a1efcb3a9..ab78b64d58 100644 --- a/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs +++ b/test/Sentry.NLog.Tests/ConfigurationExtensionsTest.cs @@ -24,6 +24,45 @@ public void AddSentry_TargetName_TargetNamed() Assert.Equal("custom", actual.AllTargets[0].Name); } + [Fact] + public void AddSentry_DefaultOptions_RuleStartsAtInfo() + { + var actual = new LoggingConfiguration().AddSentry(); + + Assert.Equal(new[] { LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Fatal }, + Assert.Single(actual.LoggingRules).Levels); + } + + [Theory] + [InlineData("Trace", "Info", "Info", "Trace")] + [InlineData("Info", "Debug", "Info", "Debug")] + [InlineData("Info", "Info", "Trace", "Trace")] + [InlineData("Off", "Off", "Warn", "Warn")] + public void AddSentry_RuleStartsAtLowestMinimumLevel(string eventLevel, string breadcrumbLevel, string logLevel, string expected) + { + var actual = new LoggingConfiguration().AddSentry(o => + { + o.MinimumEventLevel = LogLevel.FromString(eventLevel); + o.MinimumBreadcrumbLevel = LogLevel.FromString(breadcrumbLevel); + o.MinimumLogLevel = LogLevel.FromString(logLevel); + }); + + Assert.Equal(LogLevel.FromString(expected), Assert.Single(actual.LoggingRules).Levels.Min()); + } + + [Fact] + public void AddSentry_AllMinimumLevelsNull_RuleHasNoLevels() + { + var actual = new LoggingConfiguration().AddSentry(o => + { + o.MinimumEventLevel = null; + o.MinimumBreadcrumbLevel = null; + o.MinimumLogLevel = null; + }); + + Assert.Empty(Assert.Single(actual.LoggingRules).Levels); + } + [Fact] public void AddTag_SetToTarget() { From 263961de8315397e6519490c7ab8c582b9b388ea Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 11 Nov 2026 22:16:12 +1300 Subject: [PATCH 6/7] docs(nlog): drop the note about changing minimum levels after AddSentry Changing options after setup isn't supported, so it doesn't need documenting. Co-Authored-By: Claude Opus 5.5 --- src/Sentry.NLog/ConfigurationExtensions.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Sentry.NLog/ConfigurationExtensions.cs b/src/Sentry.NLog/ConfigurationExtensions.cs index 6a37750140..03542ba4b5 100644 --- a/src/Sentry.NLog/ConfigurationExtensions.cs +++ b/src/Sentry.NLog/ConfigurationExtensions.cs @@ -55,8 +55,7 @@ public static LoggingConfiguration AddSentry( /// /// This doesn't initialise Sentry. Initialise Sentry separately, using SentrySdk.Init or another Sentry /// integration (such as ASP.NET Core or MAUI). - /// The rule it adds starts at the lowest of the target's minimum levels. Lowering one of them after calling this - /// method doesn't let lower entries through. + /// The rule it adds starts at the lowest of the target's minimum levels. /// /// The NLog configuration. /// An optional action for configuring the Sentry target options. From 9a93a528c2b74f14bd096605b1286975ef33d6ec Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 11 Nov 2026 22:33:57 +1300 Subject: [PATCH 7/7] fix(nlog): make enableLogs="false" set MinimumLogLevel to Off In 6.x enableLogs="false" turned logs off. It was only a warning in 7.0 because the target had no way to turn logs off; MinimumLogLevel now gives it one, so existing configs keep their meaning. Co-Authored-By: Claude Opus 5.5 --- src/Sentry.NLog/SentryTarget.cs | 17 ++++++----------- ...piApprovalTests.Run.DotNet10_0.verified.txt | 4 ++-- ...piApprovalTests.Run.DotNet11_0.verified.txt | 4 ++-- ...ApiApprovalTests.Run.DotNet8_0.verified.txt | 4 ++-- ...ApiApprovalTests.Run.DotNet9_0.verified.txt | 4 ++-- .../ApiApprovalTests.Run.Net4_8.verified.txt | 4 ++-- .../SentryTargetConfigurationBindingTests.cs | 18 +++++------------- test/Sentry.NLog.Tests/SentryTargetTests.cs | 18 ++++++++++++++++-- 8 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/Sentry.NLog/SentryTarget.cs b/src/Sentry.NLog/SentryTarget.cs index 42b6937435..5b5cb43259 100644 --- a/src/Sentry.NLog/SentryTarget.cs +++ b/src/Sentry.NLog/SentryTarget.cs @@ -147,29 +147,24 @@ public string MinimumLogLevel } internal const string ObsoleteEnableLogs = - "This option is ignored and will be removed in a future major version. " + - "To stop the Sentry target sending logs, set MinimumLogLevel to Off."; - - internal const string EnableLogsFalseIgnored = - "enableLogs=\"false\" no longer turns logs off. Remove enableLogs from the target configuration, " + - "and set minimumLogLevel=\"Off\" instead."; + "Use MinimumLogLevel instead. Setting this to false is the same as setting MinimumLogLevel to Off. " + + "This option will be removed in a future major version."; /// - /// No longer has any effect. Use instead. + /// Setting this to sets to Off. /// /// - /// The getter always returns . - /// Setting it to only writes a warning to standard error. + /// Setting it to has no effect. Use instead. /// [Obsolete(ObsoleteEnableLogs)] public bool EnableLogs { - get => true; + get => Options.MinimumLogLevel is { } level && level != LogLevel.Off; set { if (!value) { - WriteToStandardError("Sentry: " + EnableLogsFalseIgnored); + Options.MinimumLogLevel = LogLevel.Off; } } } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index c158c37320..76f89570ec 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -55,8 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + - " Sentry target sending logs, set MinimumLogLevel to Off.")] + [System.Obsolete("Use MinimumLogLevel instead. Setting this to false is the same as setting Minimum" + + "LogLevel to Off. This option will be removed in a future major version.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt index c158c37320..76f89570ec 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet11_0.verified.txt @@ -55,8 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + - " Sentry target sending logs, set MinimumLogLevel to Off.")] + [System.Obsolete("Use MinimumLogLevel instead. Setting this to false is the same as setting Minimum" + + "LogLevel to Off. This option will be removed in a future major version.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index c158c37320..76f89570ec 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -55,8 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + - " Sentry target sending logs, set MinimumLogLevel to Off.")] + [System.Obsolete("Use MinimumLogLevel instead. Setting this to false is the same as setting Minimum" + + "LogLevel to Off. This option will be removed in a future major version.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index c158c37320..76f89570ec 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -55,8 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + - " Sentry target sending logs, set MinimumLogLevel to Off.")] + [System.Obsolete("Use MinimumLogLevel instead. Setting this to false is the same as setting Minimum" + + "LogLevel to Off. This option will be removed in a future major version.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } diff --git a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index c158c37320..76f89570ec 100644 --- a/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.NLog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -55,8 +55,8 @@ namespace Sentry.NLog public NLog.Layouts.Layout? BreadcrumbLayout { get; set; } [System.Obsolete(@"The Sentry target no longer initializes the SDK, so a DSN can no longer be supplied to it. Initialize Sentry with SentrySdk.Init (or UseSentry via one of the integrations), and remove 'dsn', 'initializeSdk' and any other core SDK settings from the target configuration.", true)] public NLog.Layouts.Layout? Dsn { get; set; } - [System.Obsolete("This option is ignored and will be removed in a future major version. To stop the" + - " Sentry target sending logs, set MinimumLogLevel to Off.")] + [System.Obsolete("Use MinimumLogLevel instead. Setting this to false is the same as setting Minimum" + + "LogLevel to Off. This option will be removed in a future major version.")] public bool EnableLogs { get; set; } public bool IgnoreEventsWithNoException { get; set; } public bool IncludeEventDataOnBreadcrumbs { get; set; } diff --git a/test/Sentry.NLog.Tests/SentryTargetConfigurationBindingTests.cs b/test/Sentry.NLog.Tests/SentryTargetConfigurationBindingTests.cs index 8c67671c6c..ee32a0479c 100644 --- a/test/Sentry.NLog.Tests/SentryTargetConfigurationBindingTests.cs +++ b/test/Sentry.NLog.Tests/SentryTargetConfigurationBindingTests.cs @@ -123,22 +123,14 @@ public void ReportUnsupportedSdkSetting_BothSettingsOnOneTarget_WritesOnce() Assert.Single(standardError); } - [Fact] - public void EnableLogs_WhenSetToFalse_WritesMessageToStandardError() - { - var standardError = new List(); - - Set(GetTarget(standardError), "EnableLogs", false); - - Assert.Contains(SentryTarget.EnableLogsFalseIgnored, Assert.Single(standardError)); - } - - [Fact] - public void EnableLogs_WhenSetToTrue_WritesNothing() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void EnableLogs_WhenSet_WritesNothing(bool value) { var standardError = new List(); - Set(GetTarget(standardError), "EnableLogs", true); + Set(GetTarget(standardError), "EnableLogs", value); Assert.Empty(standardError); } diff --git a/test/Sentry.NLog.Tests/SentryTargetTests.cs b/test/Sentry.NLog.Tests/SentryTargetTests.cs index ce20bf057b..bd7626946d 100644 --- a/test/Sentry.NLog.Tests/SentryTargetTests.cs +++ b/test/Sentry.NLog.Tests/SentryTargetTests.cs @@ -577,7 +577,7 @@ public void MinimumBreadcrumbLevel_SetterReplacesOptions() } [Fact] - public void EnableLogs_IsObsoleteAndAlwaysEnabled() + public void EnableLogs_SetFalse_SetsMinimumLogLevelOff() { var target = (SentryTarget)_fixture.GetTarget(); @@ -586,8 +586,22 @@ public void EnableLogs_IsObsoleteAndAlwaysEnabled() target.EnableLogs = false; - Assert.True(target.EnableLogs); + Assert.False(target.EnableLogs); +#pragma warning restore CS0618 + Assert.Equal(LogLevel.Off, target.Options.MinimumLogLevel); + } + + [Fact] + public void EnableLogs_SetTrue_KeepsMinimumLogLevel() + { + _fixture.Options.MinimumLogLevel = LogLevel.Warn; + var target = (SentryTarget)_fixture.GetTarget(); + +#pragma warning disable CS0618 // Type or member is obsolete + target.EnableLogs = true; #pragma warning restore CS0618 + + Assert.Equal(LogLevel.Warn, target.Options.MinimumLogLevel); } [Fact]