Consumer Log Rotation - messagebus/lapine GitHub Wiki
The Lapine consumer process accepts an optional --logfile
parameter. When this is set, the file descriptor is never re-opened. For this reason, a copy-truncate policy should be used when rotating the consumer log, to ensure that the file descriptor does not "follow" the rotated log file.
Note that if logfile
is not configured, the consumer daemon will write its logs to STDOUT
. In this case, be very careful to ensure that your init system handles log rotation correctly.
How do I know if log rotation is broken?
Imagine, if you will, that Lapine is configured to write its log files to /var/log/lapine-consumer.log
, and that your system's log rotation service is configured to rotate it daily to /var/log/lapine-consumer.log.$DATE
. If after log rotation, no more log statements appear in /var/log/lapine-consumer.log
, chances are that you have a problem. Log rotation may be configured to move the original file, then create a new file in its old location. Check the most recent /var/log/lapine-consumer.log.$DATE
file to ensure that new log statements are not being written there.
Another symptom is that files rotated and then gzipped files may be corrupted. This can happen because the log rotation service moves the old file to a new location and gzips it, but the consumer process keeps appending to the file. Some portion of the file is now gzipped, but non-gzipped data has been appended to the end of the file.