From 095234babc25a204644fbdad0d670ac616bfc8f7 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 20 Jan 2019 16:02:30 +0100 Subject: [PATCH] Added Console log level option in configfile, which defaults to Info. --- src/NzbDrone.Core/Configuration/ConfigFileProvider.cs | 2 ++ .../Instrumentation/ReconfigureLogging.cs | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 66535daae..45972765c 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -33,6 +33,7 @@ namespace NzbDrone.Core.Configuration AuthenticationType AuthenticationMethod { get; } bool AnalyticsEnabled { get; } string LogLevel { get; } + string ConsoleLogLevel { get; } string Branch { get; } string ApiKey { get; } string SslCertHash { get; } @@ -179,6 +180,7 @@ namespace NzbDrone.Core.Configuration public string Branch => GetValue("Branch", "master").ToLowerInvariant(); public string LogLevel => GetValue("LogLevel", "Info"); + public string ConsoleLogLevel => GetValue("ConsoleLogLevel", null, persist: false); public string SslCertHash => GetValue("SslCertHash", ""); diff --git a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs index c9ad6fbe8..f5e60fdbb 100644 --- a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs +++ b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs @@ -20,11 +20,19 @@ namespace NzbDrone.Core.Instrumentation public void Reconfigure() { var minimumLogLevel = LogLevel.FromString(_configFileProvider.LogLevel); + LogLevel minimumConsoleLogLevel; + + if (_configFileProvider.ConsoleLogLevel != null) + minimumConsoleLogLevel = LogLevel.FromString(_configFileProvider.ConsoleLogLevel); + else if (minimumLogLevel > LogLevel.Info) + minimumConsoleLogLevel = minimumLogLevel; + else + minimumConsoleLogLevel = LogLevel.Info; var rules = LogManager.Configuration.LoggingRules; //Console - SetMinimumLogLevel(rules, "consoleLogger", minimumLogLevel); + SetMinimumLogLevel(rules, "consoleLogger", minimumConsoleLogLevel); //Log Files SetMinimumLogLevel(rules, "appFileInfo", minimumLogLevel <= LogLevel.Info ? LogLevel.Info : LogLevel.Off);