This article wasn't updated in the last 4 years. Please double check if the content is still up-to-date.
If you find any error, please send me a quick heads-up.
If you find any error, please send me a quick heads-up.
It is important to set up log rotation, as otherwise extensive logging could lead to the HDD being full (and the server going down).
For every type of entry you want to rotate, you should add a separate file in /etc/logrotate.d
.
For example to rotate all symfony projects in a given directory:
/var/data/www/*/var/log/*.log {
daily
missingok
rotate 7
compress
notifempty
create
}
All settings explained:
daily
: rotate dailymissingok
: don’t error if the file is missingrotate
7: keep 6 old files + the current onecompress
: compress the log after rotatingnotifempty
: don’t archive an emoty file, if the current one is emptycreate
: Creates a new file. This can optionally take a bitmask of file permissions and a user and a group (create 0644 user group
). But all omitted values are recreated like they are on the current file, so in our case: keep the user, group and file permissions the same.