Logging level can be set in the UI (immediately applied)

Logging level is set from config on startup as well
pull/4/head
Mark McDowall 11 years ago
parent 13b71bdeb7
commit 69d067d2c0

@ -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<LogLevel> GetLogLevels()
{
return new List<LogLevel>
{
LogLevel.Trace,
LogLevel.Debug,
LogLevel.Info,
LogLevel.Warn,
LogLevel.Error,
LogLevel.Fatal
};
}
public void HandleAsync(ConfigFileSavedEvent message)

@ -70,4 +70,24 @@
</div>
</div>
</fieldset>
<fieldset>
<legend>Logging</legend>
<div class="control-group">
<label class="control-label">Log Level</label>
<div class="controls">
<select name="logLevel">
<option value="Trace">Trace</option>
<option value="Debug">Debug</option>
<option value="Info">Info</option>
</select>
<span>
<i class="icon-form-danger" title="Trace and Debug logging should only be enabled temporarily"/>
</span>
</div>
</div>
</fieldset>
</div>

Loading…
Cancel
Save