Beispiel #1
0
 public LoggingSettings(string serviceName, bool printToConsole, LogLevel defaultLevel = null, LogLevel defaultRavenDBLevel = null, string logPath = null)
 {
     PrintToConsole  = printToConsole;
     LoggingLevel    = InitializeLevel("LogLevel", defaultLevel ?? LogLevel.Info);
     RavenDBLogLevel = InitializeLevel("RavenDBLogLevel", defaultRavenDBLevel ?? LogLevel.Warn);
     LogPath         = Environment.ExpandEnvironmentVariables(ConfigFileSettingsReader <string> .Read("LogPath", logPath ?? DefaultLogPathForInstance(serviceName)));
 }
Beispiel #2
0
        LogLevel InitializeLevel(string key)
        {
            var level = LogLevel.Warn;

            try
            {
                level = LogLevel.FromString(ConfigFileSettingsReader <string> .Read(key, LogLevel.Warn.Name));
            }
            catch
            {
                InternalLogger.Warn($"Failed to parse {key} setting. Defaulting to Warn.");
            }
            return(level);
        }
Beispiel #3
0
        LogLevel InitializeLevel(string key, LogLevel defaultLevel)
        {
            if (!ConfigFileSettingsReader <string> .TryRead("ServiceControl", key, out var levelText))
            {
                return(defaultLevel);
            }

            try
            {
                return(LogLevel.FromString(levelText));
            }
            catch
            {
                InternalLogger.Warn($"Failed to parse {key} setting. Defaulting to {defaultLevel.Name}.");
                return(defaultLevel);
            }
        }
Beispiel #4
0
 public LoggingSettings(string serviceName)
 {
     LoggingLevel    = InitializeLevel("LogLevel");
     RavenDBLogLevel = InitializeLevel("RavenDBLogLevel");
     LogPath         = Environment.ExpandEnvironmentVariables(ConfigFileSettingsReader <string> .Read("LogPath", DefaultLogPathForInstance(serviceName)));
 }