lxljgg
Last Updated: February 25, 2016
·
548
· jan0sch
2aaae7041aca85da930bcaf14d6768d2

Rotating rails application log files

To prevent the log files of a rails application to grow without limit you should setup log rotation. There are several ways to do this. Here is a simple solution using logrotate.

Create a config file (usually something like /etc/logrotate.d/my-app):

/full/path/to/my_rails_app/log/*.log {
   weekly
   missingok
   rotate 52
   compress
   delaycompress
   notifempty
   copytruncate
}

This will rotate logs on a weekly basis and keep them for a year. Notice that the copytruncate option is essential to prevent your rails app from having to reboot.

Say Thanks
Respond