purging log files in a production environment - restarone/violet_rails GitHub Wiki
Setup logrotate
If you are using ubuntu server 20.04+ logrotate should be installed out of the box. Crack open the configuration file:
sudo nano /etc/logrotate.conf
drop in the following configuration to rotate logs for rails:
/var/www/violet/current/log/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
copytruncate
}
after editing the configuration, run the following for the change to take effect:
sudo /usr/sbin/logrotate -f /etc/logrotate.conf
source: https://gorails.com/guides/rotating-rails-production-logs-with-logrotate