I've created a daily logrotate task to rotate the ejabberd.log. It has a post-rotate command to re-open the log. After logrotate is run ejabberd.log is renamed to ejabberd.log.1 and the new ejabberd.log is created. There are two problems after that. One, ejabberd needs to be restarted in order for it to begin writing to the logs. Even when ejabberd is restarted I get a warning that ejabberd has already been stopped. Two, ejabberd writes to the wrong log. Ejabberd somehow writes to ejabberd.log.1 instead of to the newly created ejabberd.log. I see that the log is rotated because of the timestamp on the file. Below is my logrotate for ejabberd.
/opt/ejabberd/logs/ejabberd.log {
daily
missingok
rotate 5
delaycompress
ifempty
size 500M
nomail
create 0644 root root
sharedscripts
postrotate /opt/ejabberd/bin/ejabberdctl reopen-log >/dev/null 2>/dev/null || true
endscript
}
I've tried this with ejabberd
I've tried this with ejabberd 2.1.9:
You can rotate in two different ways:
A) Let ejabberd rename and rotate:
1. ejabberd writes to ejabberd.log
2. you call: ejabberdctl rotate-log
3. ejabberd renames ejabberd.log to ejabberd-old.log
4. ejabberd writes to a new ejabberd.log
B) You rename, ejabberd rotates:
1. ejabberd writes to ejabberd.log
2. you rename ejabberd.log to whatever you want, e.g.: ejabberd.log.1
3. you call: ejabberdctl rotate-log
4. ejabberd writes to a new ejabberd.log