Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.
MIT License
1.14k stars 80 forks source link

Deleting old rolling file logs #24

Closed ShadowDancer closed 3 years ago

ShadowDancer commented 3 years ago

RollingFile should have limits, like last month, or 1gb max, to not drain disk space on customers machine. I think this is critical to have if this lib is meant to be used in production environments.

The generated files will not be deleted. If you want to do a log rotation, please do it from outside.

I think this is not good way to deal with log rotation. Especially if you have something misbehaving (generating lots of logs), the only solution is to react before disk fills up.

To solve this from outside it would be really hard to get right, as it cannot be just solved with cron job, it needs active monitoring and dealing with locked files, whereas log process already knows file masks and can correctly compute file sizes and stop logging when attempting to roll.

I think the right thing to do is stop logging, because if something is misbehaving and creating lots of log files probably cause of the problem is much more useful. If logger would remove younger logs, it could hide the cause of problem with lots of gibberish.

neuecc commented 3 years ago

A classic practice is to monitor it externally, which I believe is possible. However, this is certainly cumbersome. Shall we add a retainedFileCountLimit?

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.