Refactored logs to use a logs/ folder and also roll over after 10MB. A maximum of 5 logs will persist (50MB of log data).

This commit is contained in:
Joseph Milazzo 2021-07-28 15:07:06 -05:00
parent 58856c0d70
commit 590ee771c1
2 changed files with 13 additions and 12 deletions

View File

@ -20,6 +20,7 @@ namespace API.Services.Tasks
private readonly ILogger<BackupService> _logger;
private readonly IDirectoryService _directoryService;
private readonly string _tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp");
private readonly string _logDirectory = Path.Join(Directory.GetCurrentDirectory(), "logs");
private readonly IList<string> _backupFiles;
@ -53,7 +54,7 @@ namespace API.Services.Tasks
var fi = new FileInfo(logFileName);
var files = maxRollingFiles > 0
? _directoryService.GetFiles(Directory.GetCurrentDirectory(), $@"{fi.Name}{multipleFileRegex}\.log")
? _directoryService.GetFiles(_logDirectory, $@"{Path.GetFileNameWithoutExtension(fi.Name)}{multipleFileRegex}\.log")
: new[] {"kavita.log"};
return files;
}

View File

@ -17,10 +17,10 @@
"Microsoft.AspNetCore.Hosting.Internal.WebHost": "Information"
},
"File": {
"Path": "kavita.log",
"Path": "logs/kavita.log",
"Append": "True",
"FileSizeLimitBytes": 0,
"MaxRollingFiles": 0
"FileSizeLimitBytes": 10485760,
"MaxRollingFiles": 5
}
},
"Port": 5000