From 45ce340b7a5c6d323a59c54286d81bcffd2a87e5 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Fri, 3 May 2024 11:46:56 -0400 Subject: [PATCH] Removed ClearProviders (#1996) --- src/Hosting/Conventions/SerilogHostingConvention.cs | 8 ++++---- src/Serilog/LaunchPadLoggingOptions.cs | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Hosting/Conventions/SerilogHostingConvention.cs b/src/Hosting/Conventions/SerilogHostingConvention.cs index f5c26fa16..41dd0c752 100644 --- a/src/Hosting/Conventions/SerilogHostingConvention.cs +++ b/src/Hosting/Conventions/SerilogHostingConvention.cs @@ -63,12 +63,12 @@ public void Register(IConventionContext context, IHostApplicationBuilder builder _options.PreserveStaticLogger, _options.WriteToProviders ); - - if (context.Get() != null) - // ReSharper disable once NullableWarningSuppressionIsUsed - builder.Services.AddSingleton(context.Get()!); } + if (context.Get() != null) + // ReSharper disable once NullableWarningSuppressionIsUsed + builder.Services.AddSingleton(context.Get()!); + if (_options.WriteToProviders) return; builder.OnHostStarting( diff --git a/src/Serilog/LaunchPadLoggingOptions.cs b/src/Serilog/LaunchPadLoggingOptions.cs index eebe219d7..c8f19bece 100644 --- a/src/Serilog/LaunchPadLoggingOptions.cs +++ b/src/Serilog/LaunchPadLoggingOptions.cs @@ -3,6 +3,7 @@ namespace Rocket.Surgery.LaunchPad.Serilog; /// /// RocketSerilogOptions. /// +[PublicAPI] public class LaunchPadLoggingOptions { /// @@ -30,7 +31,7 @@ public class LaunchPadLoggingOptions /// /// Base option from the serilog package /// - public bool WriteToProviders { get; set; } = false; + public bool WriteToProviders { get; set; } /// /// Base option from the serilog package