Log rotation for passenger applications

So I was given the arduous task of creating a log rotation script for our ~150 passenger applications.

A couple of people pointed me in a direction of editing the logger settings via the applications environment.rb. In my mind I was yelling, Hell no. I'm not editing over 150 sites just for log rotation.

Logrotate came to my rescue:

$ cat /etc/logrotate.d/passenger

/home/deploy/apps/*/current/log/production.log {
    rotate 30
    su deploy deploy           #Updated 2/9/13 If the folder is not root, add this line
    create 0666 deploy deploy
        touch /home/deploy/apps/*/current/tmp/restart.txt

For SCIENCE purposes here is how to use the built in logger, but i highly advise against using it.

config.logger = Logger.new(Rails.root.join('log', "#{Rails.env}.log"), 5, 10.megabytes)  

Tim Coombs

Administrator of Slowb.ro and world leader of my own mind, the only place our ideas and thoughts are our own in a world gone mad

In a terminal https://slowb.ro

Subscribe to Slowb.ro's Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS