cocowalla / serilog-sinks-file-gzip

Plugin for the Serilog File sink that compresses output using streaming GZIP
Apache License 2.0
12 stars 1 forks source link

Invalid compressed file #5

Open szakmaster opened 1 year ago

szakmaster commented 1 year ago

We already use the log file generation with Serilog.Sinks.File in our .NET 6 project and want to add the compressed log file output to a separate folder archiving the logs. However, the created compressed files are corrupted, they are invalid.

Serilog is configured via appconfig.json:

"Serilog": { "Using": [ "SeriLog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Sinks.Async" ], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "System": "Warning" } }, "WriteTo": [ { "Name": "Console" }, { "Name": "File", "Args": { "path": "Logs/log.gz", "rollingInterval": "Day", "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog", "hooks": "Serilog.Sinks.File.GZip.GZipHooks, Serilog.Sinks.File.GZip" } }, { "Name": "File", "Args": { "path": "Logs/log.log", "rollingInterval": "Day", "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog" } } ], "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], "Properties": { "Application": "MyApplication" } } Log_error1 Log_error2

cocowalla commented 1 year ago

Hmm, is the app being properly shutdown, with a call to Serilog.Flush() before termination?

My guess here is that the ZIP write stream is being terminated while it's still being written to.