nats-server icon indicating copy to clipboard operation
nats-server copied to clipboard

Allow to set the maximum number of rotated log file

Open mcosta74 opened this issue 2 years ago • 2 comments

Feature Request

It's possible to make the NATS server producing a log file and, optionally, it's possible to enable maximum file size. When the log file reaches the maximum size, the file is rotated.

Everything works but would be nice if we could set the maximum number of "old" log file to keep. In this way we can limit the maximum disk size occupied by log files. (MAX_SIZE * MAX_NUMBER_OF_FILE)

Use Case:

The use case is nats-server running on a machine and we want to avoid that the total log files use too much disk space

Proposed Change:

Introduce a configuration setting (for instance logfile_max_count: int) that allows to set the maximum number of log files. Each time the server rotate the log file, it can check if there're already enough "old" files and deletes the oldest one before to create a new one.

Who Benefits From The Change(s)?

Whoever cannot use logrotate

Alternative Approaches

Redirect the stderr to a file and use logrotate.

mcosta74 avatar Feb 07 '23 09:02 mcosta74