serilog-sinks-file-archive
serilog-sinks-file-archive copied to clipboard
Add Retention Limit configuration
Add a Retention Limit in number of files of maximum total size occupied by the log files (I will be more interested in the first option)
Thanks for the good work. PS: I'm programing in VB.net
Thanks for opening this! This sink would indeed fit a much wider variety of use cases if it supported file retention, instead of simply overwriting the target file on every roll.
This functionality shouldn't be too difficult to add either, since it already exists in the file sink.
I'll try to add it this week, but it depends on how busy things are 👍
Hmm, so, after looking into this, it's actually more complex that I thought, for 2 reasons:
- The hook doesn't have access to the Serilog File Sink configuration (I can work around this though, or can append a date-based suffix to archived files)
- Because this hook supports tokens in target paths names, the archived files could be spread across several folders, and there is no guarantee that this hook actually created all folders matching the relevant patterns
So, I could add retention, but would only enable it if no tokens were used in the target path - but my guess is that most would prefer to use token replacement (to organise archived files into folders by date) and manage retention themselves, so I think I'd be adding extra complexity that few would use.
Very much open to other ideas here 😅
My suggestion is to add some wildcard parameter which can be used to detect the files. Something like ../_logs/archive/*/*/loggedService/log*.txt.gz
(or Regex) which will match files like ../_logs/archive/2021/02/loggedService/log20210225.txt.gz
. It should be enough for most of use cases.
I would love such feature. If it's not implemented here, I'll have to fork the project in few days :)
My suggestion is to add some wildcard parameter which can be used to detect the files. Something like
../_logs/archive/*/*/loggedService/log*.txt.gz
(or Regex) which will match files like../_logs/archive/2021/02/loggedService/log20210225.txt.gz
. It should be enough for most of use cases.I would love such feature. If it's not implemented here, I'll have to fork the project in few days :)
Did you end up forking the repo and adding this functionality?
My suggestion is to add some wildcard parameter which can be used to detect the files. Something like
../_logs/archive/*/*/loggedService/log*.txt.gz
(or Regex) which will match files like../_logs/archive/2021/02/loggedService/log20210225.txt.gz
. It should be enough for most of use cases. I would love such feature. If it's not implemented here, I'll have to fork the project in few days :)Did you end up forking the repo and adding this functionality?
Not yet. The archives are small enough to have priorities elsewhere. But it's in my backlog and current plan is to do it in few weeks (along with .xz compression).
+1 It would be very nice, if we could get this feature. We have now implement ourer own hosekeeper method.