/// <summary> /// Compresses old loader log files into a zip archive. /// </summary> private static void CompressOldLogs() { using var logCompressor = new LogFileCompressor(Paths.ArchivedLogPath); var loaderConfig = IoC.Get <LoaderConfig>(); logCompressor.AddFiles(Paths.LogPath, TimeSpan.FromHours(loaderConfig.LogFileCompressTimeHours)); logCompressor.DeleteOldFiles(TimeSpan.FromHours(loaderConfig.LogFileDeleteHours)); }
/// <summary> /// Compresses old loader log files into a zip archive. /// </summary> private static void HandleLogsAndCrashdumps() { var loaderConfig = IoC.Get <LoaderConfig>(); // Logs (delete & compress) using var logCompressor = new LogFileCompressor(Paths.ArchivedLogPath); logCompressor.AddFiles(Paths.LogPath, TimeSpan.FromHours(loaderConfig.LogFileCompressTimeHours)); logCompressor.DeleteOldFiles(TimeSpan.FromHours(loaderConfig.LogFileDeleteHours)); // Crashdumps (delete) var dumpFolders = Directory.GetDirectories(Paths.CrashDumpPath); var now = DateTime.UtcNow; foreach (var folder in dumpFolders) { var timeElapsed = now - Directory.GetLastWriteTimeUtc(folder); if (timeElapsed.TotalHours > loaderConfig.CrashDumpDeleteHours) { IOEx.TryDeleteDirectory(folder); } } }