diff --git a/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs b/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs index 6067146b6..bc3f0e3d7 100644 --- a/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs +++ b/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs @@ -31,13 +31,42 @@ namespace NzbDrone.Core.Instrumentation public void Reconfigure() { - var logLevel = _configFileProvider.LogLevel; + var minimumLogLevel = LogLevel.FromString(_configFileProvider.LogLevel); var rules = LogManager.Configuration.LoggingRules; var rollingFileLogger = rules.Single(s => s.Targets.Any(t => t.Name == "rollingFileLogger")); rollingFileLogger.EnableLoggingForLevel(LogLevel.Trace); - var test = 1; + SetMinimumLogLevel(rollingFileLogger, minimumLogLevel); + } + + private void SetMinimumLogLevel(LoggingRule rule, LogLevel minimumLogLevel) + { + foreach (var logLevel in GetLogLevels()) + { + if (logLevel < minimumLogLevel) + { + rule.DisableLoggingForLevel(logLevel); + } + + else + { + rule.EnableLoggingForLevel(logLevel); + } + } + } + + private List GetLogLevels() + { + return new List + { + LogLevel.Trace, + LogLevel.Debug, + LogLevel.Info, + LogLevel.Warn, + LogLevel.Error, + LogLevel.Fatal + }; } public void HandleAsync(ConfigFileSavedEvent message) diff --git a/UI/Settings/General/GeneralTemplate.html b/UI/Settings/General/GeneralTemplate.html index 2650cca79..6325f37c1 100644 --- a/UI/Settings/General/GeneralTemplate.html +++ b/UI/Settings/General/GeneralTemplate.html @@ -70,4 +70,24 @@ + +
+ Logging + +
+ + +
+ + + + + +
+
+