Posted over 6 years ago. Visible to the public.

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):

Copy
/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.

Owner of this card:

Avatar
jan0sch
Last edit:
over 6 years ago
Posted by jan0sch to jan0sch's deck
This website uses cookies to improve usability and analyze traffic.
Accept or learn more