Commit 63d6d367 authored by AntekZ's avatar AntekZ

compression removed, rotate files at 2MB instead of 20MB

parent 42775126
......@@ -73,7 +73,7 @@ namespace LcdLogger.Services
return Task.CompletedTask;
}
var files = DirectoryInfo.GetFiles("lcd-*.log*").OrderBy(f => f.Name).ToList();
var files = DirectoryInfo.GetFiles("lcd-*.log").OrderBy(f => f.Name).ToList();
long totalBytes = files.Sum(f => f.Length);
......@@ -108,35 +108,35 @@ namespace LcdLogger.Services
var justClosedFile = _currentPath;
_ = Task.Run(async () =>
{
await CompressAsync(justClosedFile);
});
//_ = Task.Run(async () =>
//{
// await CompressAsync(justClosedFile);
//});
await PruneSurplusFilesAsync(cancellationToken);
await OpenNewAsync(cancellationToken);
}
private async Task CompressAsync(string path)
{
try
{
var gzPath = path + ".gz";
using (var source = File.OpenRead(path))
using (var destination = File.Create(gzPath))
using (var gzip = new GZipStream(destination, CompressionLevel.SmallestSize))
{
await source.CopyToAsync(gzip);
}
File.Delete(path);
}
catch (Exception e)
{
_logger.LogError(e.Message, "Compress failed");
}
}
//private async Task CompressAsync(string path)
//{
// try
// {
// var gzPath = path + ".gz";
// using (var source = File.OpenRead(path))
// using (var destination = File.Create(gzPath))
// using (var gzip = new GZipStream(destination, CompressionLevel.SmallestSize))
// {
// await source.CopyToAsync(gzip);
// }
// File.Delete(path);
// }
// catch (Exception e)
// {
// _logger.LogError(e.Message, "Compress failed");
// }
//}
public async ValueTask DisposeAsync()
{
......
{
"Log": {
"Directory": "/var/log/lcd-logger",
"RotateAtBytes": 20971520,
"RotateAtBytes": 2097152,
"MaxTotalBytes": 104857600,
"MinLevel": 2,
"MaxBatchEntries": 100,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment