We've been using syslog-ng to log our postgres logs. On top of it we run logrotate every 5 minutes which also gzips the files. Recently, we've noted that these postgres logs contain a lot of null characters at the beginning of the file. We later realized that the space occupied by the null characters are equal to the previous size of the file.
Researching (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733856) on why sparsing has been taking place we realized that the problem lies with syslog-ng not being able to write the logs from the beginning. We tried writing a postrotate script which would kill -HUP syslog-ng. We tried that, but in vain. Many have sorted out this problem by setting the o_append bit. Does anyone know how to set the o_append bit for syslog-ng so that it does not write from the last maintained write head and starts from the beginning of the file?
copytruncate
, perhaps you shouldn't.copytruncate
has a lot of overhead compared to simply renaming the files. Also apparently you need to restartsyslog-ng
, it has no mechanism for reopening the files, so aSIGHUP
won't be enough (that only makes it reread the config).