diff --git a/src/Hosting/Conventions/SerilogHostingConvention.cs b/src/Hosting/Conventions/SerilogHostingConvention.cs index f5c26fa16..295f0a1fe 100644 --- a/src/Hosting/Conventions/SerilogHostingConvention.cs +++ b/src/Hosting/Conventions/SerilogHostingConvention.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Rocket.Surgery.Conventions; +using Rocket.Surgery.Conventions.Logging; using Rocket.Surgery.Hosting; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; @@ -63,12 +64,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( @@ -84,4 +85,4 @@ public void Register(IConventionContext context, IHostApplicationBuilder builder ) ); } -} \ No newline at end of file +} diff --git a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs index 29b1badcf..35a44f63f 100644 --- a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs +++ b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs @@ -1,7 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Rocket.Surgery.Conventions; +using Rocket.Surgery.Conventions.Logging; using Serilog; namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; @@ -44,4 +46,5 @@ LoggerConfiguration loggerConfiguration post.PostConfigure(Options.DefaultName, loggerConfiguration); } } -} \ No newline at end of file +} + diff --git a/src/Serilog/LaunchPadLoggingOptions.cs b/src/Serilog/LaunchPadLoggingOptions.cs index eebe219d7..815c21873 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,10 +31,10 @@ 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 /// public bool PreserveStaticLogger { get; set; } -} \ No newline at end of file +}