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.
Written by Jens Grassel
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#