mirror of
https://github.com/Radarr/Radarr
synced 2024-12-23 00:12:44 +00:00
New: Trace/Debug logging will keep the last 50 files instead of only the last 5
This commit is contained in:
parent
0628b3dc2d
commit
0c839d1e11
2 changed files with 25 additions and 12 deletions
|
@ -10,16 +10,11 @@
|
|||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
public interface ISetLoggingLevel
|
||||
{
|
||||
void Reconfigure();
|
||||
}
|
||||
|
||||
public class SetLoggingLevel : ISetLoggingLevel, IHandleAsync<ConfigFileSavedEvent>, IHandleAsync<ApplicationStartedEvent>
|
||||
public class ReconfigureLogging : IHandleAsync<ConfigFileSavedEvent>, IHandleAsync<ApplicationStartedEvent>
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
|
||||
public SetLoggingLevel(IConfigFileProvider configFileProvider)
|
||||
public ReconfigureLogging(IConfigFileProvider configFileProvider)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
}
|
||||
|
@ -29,10 +24,11 @@ public void Reconfigure()
|
|||
var minimumLogLevel = LogLevel.FromString(_configFileProvider.LogLevel);
|
||||
|
||||
var rules = LogManager.Configuration.LoggingRules;
|
||||
var rollingFileLogger = rules.Single(s => s.Targets.Any(t => t is NzbDroneFileTarget));
|
||||
rollingFileLogger.EnableLoggingForLevel(LogLevel.Trace);
|
||||
|
||||
SetMinimumLogLevel(rollingFileLogger, minimumLogLevel);
|
||||
var rollingFileLoggerRule = rules.Single(s => s.Targets.Any(t => t is NzbDroneFileTarget));
|
||||
rollingFileLoggerRule.EnableLoggingForLevel(LogLevel.Trace);
|
||||
|
||||
SetMinimumLogLevel(rollingFileLoggerRule, minimumLogLevel);
|
||||
SetMaxArchiveFiles(rollingFileLoggerRule, minimumLogLevel);
|
||||
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
@ -53,6 +49,23 @@ private void SetMinimumLogLevel(LoggingRule rule, LogLevel minimumLogLevel)
|
|||
}
|
||||
}
|
||||
|
||||
private void SetMaxArchiveFiles(LoggingRule rule, LogLevel minimumLogLevel)
|
||||
{
|
||||
var target = rule.Targets.Single(t => t is NzbDroneFileTarget) as NzbDroneFileTarget;
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
if (minimumLogLevel >= LogLevel.Info)
|
||||
{
|
||||
target.MaxArchiveFiles = 5;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
target.MaxArchiveFiles = 50;
|
||||
}
|
||||
}
|
||||
|
||||
private List<LogLevel> GetLogLevels()
|
||||
{
|
||||
return new List<LogLevel>
|
|
@ -436,7 +436,7 @@
|
|||
<Compile Include="Instrumentation\Log.cs" />
|
||||
<Compile Include="Instrumentation\LogRepository.cs" />
|
||||
<Compile Include="Instrumentation\LogService.cs" />
|
||||
<Compile Include="Instrumentation\SetLoggingLevel.cs" />
|
||||
<Compile Include="Instrumentation\ReconfigureLogging.cs" />
|
||||
<Compile Include="Jobs\JobRepository.cs" />
|
||||
<Compile Include="Jobs\ScheduledTask.cs" />
|
||||
<Compile Include="Jobs\Scheduler.cs" />
|
||||
|
|
Loading…
Reference in a new issue