Open szakmaster opened 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" } }
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.
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" } }