There is a web application (php/apache2) which opens a log file somewhere at a start of a request handling and closes it (as far as I know) when the handling is finished. Between log file open and close, entries are of course written.
Let's assume that somewhere in a middle of a request handling (i.e. some log entries were already written and some were not yet written) log rotation using logrotate
is performed and its configuration is like following:
/var/log/some/path/*.log {
weekly
missingok
rotate 30
compress
delaycompress
notifempty
create <mode> <owner> <group>
size 10M
}
If I understand the logrotate man page, the create
directive will cause the current log file (the file which is open by the request handling being in progress) to be renamed/moved and a new, empty log file to be created. If so, then what will happen to not yet written log entries generated by the request handling in progress? Will they be appended to the renamed/moved file or maybe they will be lost? The second question is about the postrotate
and or prerotate
directives. Do I need them in my case? The only thing I can think about to put in them is an apache graceful restart command but do I actually need it?