@@ -3,14 +3,33 @@ namespace ServiceControl.Infrastructure;
33using System ;
44using System . Collections . Generic ;
55using System . IO ;
6+ using System . Linq ;
67using Microsoft . Extensions . Logging ;
78using ServiceControl . Configuration ;
89
9- public class LoggingSettings ( SettingsRootNamespace rootNamespace , LogLevel defaultLevel = LogLevel . Information , string logPath = null )
10+ public class LoggingSettings
1011{
11- public LogLevel LogLevel { get ; } = InitializeLogLevel ( rootNamespace , defaultLevel ) ;
12+ public LoggingSettings ( SettingsRootNamespace rootNamespace , LogLevel defaultLevel = LogLevel . Information , string logPath = null )
13+ {
14+ LogLevel = InitializeLogLevel ( rootNamespace , defaultLevel ) ;
15+ LogPath = SettingsReader . Read ( rootNamespace , logPathKey , Environment . ExpandEnvironmentVariables ( logPath ?? DefaultLogLocation ( ) ) ) ;
16+
17+ var loggingProviders = SettingsReader . Read < string > ( rootNamespace , loggingProvidersKey ) . Split ( "," ) ;
18+ var activeLoggers = Loggers . None ;
19+ if ( loggingProviders . Contains ( "NLog" ) )
20+ {
21+ activeLoggers |= Loggers . NLog ;
22+ }
23+ if ( loggingProviders . Contains ( "Seq" ) )
24+ {
25+ activeLoggers |= Loggers . Seq ;
26+ }
27+ LoggerUtil . ActiveLoggers = activeLoggers ;
28+ }
29+
30+ public LogLevel LogLevel { get ; }
1231
13- public string LogPath { get ; } = SettingsReader . Read ( rootNamespace , logPathKey , Environment . ExpandEnvironmentVariables ( logPath ?? DefaultLogLocation ( ) ) ) ;
32+ public string LogPath { get ; }
1433
1534 static LogLevel InitializeLogLevel ( SettingsRootNamespace rootNamespace , LogLevel defaultLevel )
1635 {
@@ -57,4 +76,5 @@ static LogLevel ParseLogLevel(string value, LogLevel defaultLevel)
5776
5877 const string logLevelKey = "LogLevel" ;
5978 const string logPathKey = "LogPath" ;
79+ const string loggingProvidersKey = "LoggingProviders" ;
6080}
0 commit comments