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

Is there a way to control how rotated log files are renamed? #172

Open
Elcoid opened this issue Sep 20, 2024 · 3 comments
Open

Is there a way to control how rotated log files are renamed? #172

Elcoid opened this issue Sep 20, 2024 · 3 comments

Comments

@Elcoid
Copy link

Elcoid commented Sep 20, 2024

Hello!

I see that rotating with Numbers yields files that look like this:

my_daemon_rCURRENT.log
my_daemon_r00000.log
my_daemon_r00001.log
...

and rotating with NumbersDirect yields files that look like this:

my_daemon_r00000.log
my_daemon_r00001.log
my_daemon_r00002.log
...

However, I would like to be able to have the following (as is usual on *nix from what I could see, and this is what file_rotate does by default), is it possible?

my_daemon.log
my_daemon.log.1
my_daemon.log.2
...
@emabee
Copy link
Owner

emabee commented Sep 22, 2024

That's not implemented so far - thanks for the proposal!

@emabee
Copy link
Owner

emabee commented Sep 24, 2024

May I ask about the advantage of this approach, as it comes with the disadvantage that the rotated files cannot be easily recognized as log files?

@Elcoid
Copy link
Author

Elcoid commented Sep 24, 2024

First, it's pretty standard on Unix systems. For example, here on an Ubuntu machine, in /var/log I have boot.log, boot.log.1, boot.log.2, ... (Other daemons also compress older rotated logs while other start at 0 instead of 1, so I also have dpkg.log, dpkg.log.1, dpkg.log.2.gz, dpkg.log.3.gz, ... and dmesg, dmesg.0, dmesg.1.gz, dmesg.2.gz in the same directory.)

So there might be people with scripts and frameworks already written for this type of naming scheme.

Second, in my case specifically, I have a service writing in a log and another process monitoring the log and sending alerts when it reads certain keywords (like errors and so on). Initially, both services were reading the path of the log file from the same config file. However when I enabled log rotation, I had to split the config to tell the first service to write to /path/to/file.log but tell the second service to monitor /path/to/file_rCURRENT.log.

Then, when I receive an alert and want to copy the log files from the server for analysis, I could select the path in the config and add a wildcard (*) at the end to include the current log and all the rotated ones (i.e. /path/to/file.log* would include file.log, file.log.1, file.log.2, etc.). However, with an infix, I have to parse the path and insert the wildcard before the trailing .log to do the same thing (/path/to/file*.log), which is slightly more complicated.

So all in all, it's not a dealbreaker, but it would make things smoother.

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

No branches or pull requests

2 participants