I'm not sure what the correct way is because earlier today I've come across this question only because I was looking for the same answer.
I think this approach would work, however it has two relatively minor problems (if you can even call them that):
- There is a race condition window where log data might get lost between the time logrotate makes a copy of the data and when truncation of that data happens
- Logrotate has to copy the entire file, which seems a bit wasteful compared with the typical approach of SIGHUP which closes/reopens log files.
In my own search, I'm now contemplating of switching from FileAppender (or Rolling one) to a SysLogAppender and using logrotate with rsyslog, both of which work very naturally together. Then again, the reason I'm considering this is because we have other python daemons in our systems and those daemons already use rsyslog. My only reservation of switching to SysLogAppender is that I don't know how it handles exception stack traces since syslog doesn't allow messages longer than 1024 chars.
And in answer to Martin Schroder's comments, I think I want to make the switch for the reason as you are. So that our logging configuration across all our services is configured and handled the same way and has the same behavior.