Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set the maximum number of rotated log file #3851

Open
mcosta74 opened this issue Feb 7, 2023 · 2 comments
Open

Allow to set the maximum number of rotated log file #3851

mcosta74 opened this issue Feb 7, 2023 · 2 comments
Assignees
Labels
proposal Enhancement idea or proposal

Comments

@mcosta74
Copy link

mcosta74 commented Feb 7, 2023

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.

@derekcollison
Copy link
Member

@bruth bruth added proposal Enhancement idea or proposal and removed 🎉 enhancement labels Aug 18, 2023
@zakk616
Copy link

zakk616 commented Aug 25, 2024

I also tried to configure to archive or remove old logs using logrotate based on file extension, since the rotated file logs contain an extension of suffix: .yyyy.mm.dd.hh.mm.ss.micros which is making it difficult to select using logrotate.
I have proposed a PR #5815 which rotates logs with .log file extension like:
nats-server.2024.08.25.14.37.57.558600300.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

5 participants