I wrote a small c app that uses the syslog c interface to write messages (from man 3 syslog):
void openlog(const char *ident, int logopt, int facility); void syslog(int priority, const char *message, ...); void closelog(void);
My question: I'm writing messages to LOCAL0 in
/var/log/local0.log. I also have cron calling logrotate on
/var/log/local0.log. I've noticed that after the rotation, my app continues writing to the file that was rotated out instead of the new
What is the best way to fix this with a postrotate script?
Easy, but not ideal: completely restart the rsyslog daemon.
Send and handle SIGHUP in my app. This seems like the most appropriate solution. But I'm not sure what I need to do when I get the HUP. Do I just need to call closelog() then openlog()?