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

close and re-create/-open log file(s) on SIGNAL #4878

Open
sock3t opened this issue Jun 29, 2022 · 2 comments
Open

close and re-create/-open log file(s) on SIGNAL #4878

sock3t opened this issue Jun 29, 2022 · 2 comments

Comments

@sock3t
Copy link

sock3t commented Jun 29, 2022

Challenge:
To maintain log file disk usage you have to accomplish 2 main points:

  • rotate and compress the log files regularly
  • get rid of old logs after a certain expiration time

Proposed solution:
A solution to this is possible today already via logrotate:
https://www.traccar.org/forums/topic/log-file-size/#post-72460

Also considered but much more effort:
#3994
^^ this might be another option but would required integration with a variety of syslogging products. It has to be considered that Traccar is used on other platforms apart from Linux+rsyslog.

Why logrotate?
Logrotate or other similar log rotation mechanisms don't require complex integration and code change but mostly work out of the box.

What is missing:
Yet there is one item that could be improved: Once a log file has been renamed (rotated) Traccar is required start writing into a new log file with the same name, so basically re-create the original (now empty) log file. Currently this can be achieved by restarting Traccar entirely but means an interruption of service and a potential loss of communication - especially on large systems.

So it is desired to have a functionality to send a signal to the running Traccar server which triggers the closing and re-creation of the log file while keeping the rest of the service running. Similar to how it is described here: log4js-node/log4js-node#343

@tananaev
Copy link
Member

Can you use console logger and just pipe it to syslog or some other external logging system?

@twouters
Copy link

twouters commented Jul 8, 2022

You don't have to restart the traccar service if you add the copytruncate option to the logrotate config.

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

No branches or pull requests

3 participants