From 464871ca161b9f406f1a49c308400d546af89c58 Mon Sep 17 00:00:00 2001 From: David Allardyce Date: Fri, 15 Mar 2024 12:54:28 -0400 Subject: [PATCH 1/2] Use value from `Serilog:MinimumLevel:Default` if value from `Serilog:MinimumLevel` is an empty string --- .../Configuration/ConfigurationReader.cs | 4 ++-- .../LoggerConfigurationExtensionsTests.cs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs b/src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs index 1049b85..bad9fdc 100644 --- a/src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs +++ b/src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs @@ -200,12 +200,12 @@ void ApplyMinimumLevelConfiguration(IConfigurationSection directive, Action + { + ["Serilog"] = "", + ["Serilog:MinimumLevel"] = "", + ["Serilog:MinimumLevel:Default"] = "Information", + + }) + .Build(); + + new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + } } From 1d62cc4b44c14ac49813541d82b81bde9a8cc7fc Mon Sep 17 00:00:00 2001 From: David Allardyce <93950725+DavidAllardyce@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:48:26 -0400 Subject: [PATCH 2/2] Update test/Serilog.Settings.Configuration.Tests/LoggerConfigurationExtensionsTests.cs Co-authored-by: Ivan Maximov --- .../LoggerConfigurationExtensionsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Serilog.Settings.Configuration.Tests/LoggerConfigurationExtensionsTests.cs b/test/Serilog.Settings.Configuration.Tests/LoggerConfigurationExtensionsTests.cs index 4787df0..583a53a 100644 --- a/test/Serilog.Settings.Configuration.Tests/LoggerConfigurationExtensionsTests.cs +++ b/test/Serilog.Settings.Configuration.Tests/LoggerConfigurationExtensionsTests.cs @@ -142,7 +142,7 @@ public void ReadFromConfigurationSectionDoesNotThrowWhenTryingToCallConfiguratio [Fact] [Trait("BugFix", "https://github.com/serilog/serilog-settings-configuration/issues/332")] - public void ReadFromConfigurationThrowsWhenMinimumLevelDefaultSetButMinimumLevelValueIsEmptyString() + public void ReadFromConfiguration_ShouldNot_Throw_When_MinimumLevel_Default_Set_But_MinimumLevel_Value_Is_Empty_String() { var configuration = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary