Normal rotation renames app.log to app.log.1 and expects the program to start a fresh file. Plenty of programs don’t. They keep the old file open and go on writing into app.log.1, while the new app.log stays empty.
The copytruncate option in logrotate is made for them. It copies the log to the rotated name and then truncates the original to zero bytes in place, so the program keeps its open file and carries on writing into it.
/var/log/myapp/*.log {
weekly
rotate 4
compress
missingok
copytruncate
}
Save that as /etc/logrotate.d/myapp and the regular logrotate run picks it up. I’d reach for this when a script or a small daemon writes its own log file and has no way to reopen it. When a program can reopen its log on a signal or a reload, a postrotate script that triggers that is the cleaner route.
The caveat is right there in the man page: between the copy and the truncate there’s a very small window, and anything written in that moment is lost. For a hobby service I can live with that, for logs you need as evidence later I wouldn’t. Also, a create line does nothing together with copytruncate, because the original file never goes away.
Further reading: logrotate(8) man page