mirror of https://github.com/Radarr/Radarr
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
|
@ -10,16 +10,11 @@ using NzbDrone.Core.Messaging.Events;
|
|||
|
||||
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 @@ namespace NzbDrone.Core.Instrumentation
|
|||
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 @@ namespace NzbDrone.Core.Instrumentation
|
|||
}
|
||||
}
|
||||
|
||||
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 New Issue