示例#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)));
 }
示例#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);
        }
示例#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);
            }
        }
示例#4
0
 public LoggingSettings(string serviceName)
 {
     LoggingLevel    = InitializeLevel("LogLevel");
     RavenDBLogLevel = InitializeLevel("RavenDBLogLevel");
     LogPath         = Environment.ExpandEnvironmentVariables(ConfigFileSettingsReader <string> .Read("LogPath", DefaultLogPathForInstance(serviceName)));
 }