Logfile rotation

Heyou,

just a simple question. What’s the current best practice for logfile rotation? I start syncthing on FreeBSD with -logfile /var/log/syncthing.log. I have a newsyslog.conf line, which rotates that file daily:

/var/log/syncthing.log	syncthing:syncthing	644	7	*	@T00	XC	/var/run/syncthing.pid

“Problem” is that newsyslog sends SIGHUP to syncthing which restarts syncthing. I think it is not needed to restart syncthing completely when the logfile-filedescriptor changes. What’s the cleanest way to do this? Why don’t we have a SIGHUP handler that reloads the logfile, and, for instance a SIGUSR1 handler which restarts syncthing instead?

Thanks!

I think this is in the current stable version, so there should be no need to signal the rotation to Syncthing.

1 Like

I feel that this might cause dropped log messages? Are they buffered when the logfile has not been reopened yet?

No, it’s open()ed from within write() when necessary.

However as you’re running it as a service of some kind you might want to just integrate it with syslog instead anyway. I usually end up with something similar to syncthing -no-restart -logflags 0 | logger -t syncthing and then routing the messages appropriately in your syslog config.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.