serilog-sinks-file icon indicating copy to clipboard operation
serilog-sinks-file copied to clipboard

Allow rolling directorys

Open MathisDukatz opened this issue 7 months ago • 1 comments

Is your feature request related to a problem? Please describe. It's less of a problem but more of a usecase. In my project a lot of files are created in distinct folders. Every day a new sprint starts and new folders are created collecting todays files. Only serilog logs into the same folder for the app logs only rolling the file name. This makes it harder for datacrawlers and harder to combine multiple app logs per day from diffrent apps as all days are in one folder and need to be filtered.

Describe the solution you'd like Enable rolling not only for files but also for directories. For example path/to/log_day20250420/my.log -> path/to/log_day20250421/my.log.

Describe alternatives you've considered Creating a path programmatically for every day would be possible but we configured multiple sinks over muliple json files and putting all this logic into app code isn't very appealing.

Additional context I'm willing to contribute to this feature / implementing it but would first like to know if it is even wanted/ will be accepted.

MathisDukatz avatar Apr 25 '25 14:04 MathisDukatz

Hi @MathisDukatz, thanks for the note and the offer of help.

This is a valid use case, but in previous discussions of similar features we've chosen to avoid the additional complexity in this sink, in order to keep things lean/maintainable over long periods of time.

There are a couple of alternatives and forks out there that enable other scenarios, though, so there might already be one that covers this case.

Otherwise, putting together a custom sink that reuses FileSink from this package (or the LoggerSinkConfiguration.CreateSink() function, which opens up more functionality) should be fairly workable.

nblumhardt avatar Apr 28 '25 00:04 nblumhardt