Closed schaapkabap closed 9 months ago
Hi, sorry it's taken me a while to get to this 😅
I've taken a look at the code in question, and I think it's perhaps a typo; I think it should really be making the same check that the other ctor does: compressionLevel == CompressionLevel.NoCompression && targetDirectory == null
(the purpose of which is explained here, but when I fix this I'll add to the code comments!).
@EamonHetherton as the original author, do you concur?
Cool, that makes more sense. I updated already the #17 for it :)
I can't recall specifically, and I don't use it without compression. Having a quick look at the code, it might have been an overly defensive move due to the LogFileComparer being very basic and only ordering by name. Depending on your file name format, without compression it could possibly remove the current file instead of only archive files? When compression is used it filters to *.gz files first so while it could still end up doing something unexpected, it would only affect the archived files not the current uncompressed log file. The current implementation meets all my needs so I haven't bothered to improve it but I'm happy if this check is removed; it won't affect my use.
Fixed by #17. v1.0.5 now released to NuGet: https://www.nuget.org/packages/Serilog.Sinks.File.Archive/1.0.5
If I'm using
CompressionLevel.NoCompression
andretainedFileCountLimit
its not possible to execute that action. Meanwhile if I remove the following code it is possible. What's the reason to decline that combination and is possible to remove that check?