Rails.logger

suggest change

Use Rails.logger.debug, info, warn, error, or fatal rather than puts. The log line then has the standard format, a timestamp, and a level, so you can decide what a given environment shows. Files live in log/ and are named after RAILS_ENV, such as development.log and production.log. staging.log appears only when you boot with RAILS_ENV=staging.

Rotate production logs with logrotate:

Open /etc/logrotate.conf with your favourite linux editor vim or nano and add the below code in this file at bottom.

/YOUR/RAILSAPP/PATH/log/*.log { 
  daily
  missingok
  rotate 7
  compress
  delaycompress
  notifempty
  copytruncate
}

So, How It Works This is fantastically easy. Each bit of the configuration does the following:

Running Logrotate Since we just wrote this configuration, you want to test it.

To run logrotate manually, just do: sudo /usr/sbin/logrotate -f /etc/logrotate.conf

That’s it.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents