Skip to content

Commit 093279a

Browse files
committed
Set default logging provider to NLog and add null argument validation in logging settings initialization
1 parent 39a65cc commit 093279a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/ServiceControl.Infrastructure/LoggerOptionsExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public static class LoggerOptionsExtensions
99
{
1010
public static LoggingSettings ToLoggingSettings(this LoggingOptions src)
1111
{
12+
ArgumentNullException.ThrowIfNull(src);
13+
1214
LoggingSettings dst = new();
1315

1416
var activeLoggers = Loggers.None;
@@ -32,7 +34,9 @@ public static LoggingSettings ToLoggingSettings(this LoggingOptions src)
3234
}
3335

3436
//this defaults to NLog because historically that was the default, and we don't want to break existing installs that don't have the config key to define loggingProviders
35-
LoggerUtil.ActiveLoggers = activeLoggers == Loggers.None ? Loggers.NLog : activeLoggers;
37+
LoggerUtil.ActiveLoggers = activeLoggers == Loggers.None
38+
? Loggers.NLog
39+
: activeLoggers;
3640

3741
dst.LogLevel = InitializeLogLevel(src.LogLevel, dst.LogLevel);
3842
dst.LogPath = Environment.ExpandEnvironmentVariables(src.LogPath ?? DefaultLogLocation());

src/ServiceControl.Infrastructure/LoggingSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public record LoggingOptions
66
{
77
public string LogLevel { get; set; } = "Information";
88
public string LogPath { get; set; }
9-
public string LoggingProviders { get; set; }
9+
public string LoggingProviders { get; set; } = "NLog";
1010
public string SeqAddress { get; set; }
1111
}
1212

0 commit comments

Comments
 (0)