1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-26 01:37:07 +00:00

Added Console log level option in configfile, which defaults to Info.

This commit is contained in:
Taloth Saldono 2019-01-20 16:02:30 +01:00
parent 8aecec507e
commit 095234babc
2 changed files with 11 additions and 1 deletions

View file

@ -33,6 +33,7 @@ namespace NzbDrone.Core.Configuration
AuthenticationType AuthenticationMethod { get; } AuthenticationType AuthenticationMethod { get; }
bool AnalyticsEnabled { get; } bool AnalyticsEnabled { get; }
string LogLevel { get; } string LogLevel { get; }
string ConsoleLogLevel { get; }
string Branch { get; } string Branch { get; }
string ApiKey { get; } string ApiKey { get; }
string SslCertHash { get; } string SslCertHash { get; }
@ -179,6 +180,7 @@ namespace NzbDrone.Core.Configuration
public string Branch => GetValue("Branch", "master").ToLowerInvariant(); public string Branch => GetValue("Branch", "master").ToLowerInvariant();
public string LogLevel => GetValue("LogLevel", "Info"); public string LogLevel => GetValue("LogLevel", "Info");
public string ConsoleLogLevel => GetValue("ConsoleLogLevel", null, persist: false);
public string SslCertHash => GetValue("SslCertHash", ""); public string SslCertHash => GetValue("SslCertHash", "");

View file

@ -20,11 +20,19 @@ namespace NzbDrone.Core.Instrumentation
public void Reconfigure() public void Reconfigure()
{ {
var minimumLogLevel = LogLevel.FromString(_configFileProvider.LogLevel); 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; var rules = LogManager.Configuration.LoggingRules;
//Console //Console
SetMinimumLogLevel(rules, "consoleLogger", minimumLogLevel); SetMinimumLogLevel(rules, "consoleLogger", minimumConsoleLogLevel);
//Log Files //Log Files
SetMinimumLogLevel(rules, "appFileInfo", minimumLogLevel <= LogLevel.Info ? LogLevel.Info : LogLevel.Off); SetMinimumLogLevel(rules, "appFileInfo", minimumLogLevel <= LogLevel.Info ? LogLevel.Info : LogLevel.Off);