With compress alone, logrotate gzips the old file right away. That is a problem if the program still has it open and keeps writing for a while.
Add delaycompress next to it:
/var/log/myapp/*.log {
daily
rotate 14
compress
delaycompress
missingok
notifempty
}
Now the most recently rotated file stays as plain text, for example app.log.1, and it is compressed at the next rotation. Older ones are .gz as before.
There is a bonus for troubleshooting. Yesterday’s log can be read and searched with ordinary grep and less, which is the file I reach for most after the current one.
The man page suggests it for programs that cannot be told to close their log file straight away. A web server that is reloaded by a postrotate script can still have old workers finishing requests, and this gives them time.
Check your syntax without rotating anything:
sudo logrotate -d /etc/logrotate.d/myapp
The option does nothing without compress. It also does not help a program that never reopens its file at all; that one keeps writing into the renamed file until you restart it. And you use a bit more disk, which matters if a single day of logs is huge.
Further reading: logrotate man page