Ruby on Rails - rails.logger in ruby on rails - ruby on rails tutorial - rails guides - rails tutorial - ruby rails



Rails.logger

Always use Rails.logger rather than puts. This allows your logs to fit into the standard log format, have a timestamp and have a level so we choose whether they are important enough to be shown in a specific environment. We can see the separate log files for our application under log/ directory with our rails app environment.

You can easily rotating rails production logs with LogRotate.You just have to do small configuration as below Open /etc/logrotate.conf with our 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:

  • daily – Rotate the log files each day. You can also use weekly or monthly here instead.
  • missingok – If the log file doesn’t exist,ignore it
  • rotate 7 – Only keep 7 days of logs around
  • compress – GZip the log file on rotation
  • delaycompress – Rotate the file one day, then compress it the next day so we can be sure that it won’t interfere with the Rails server
  • notifempty – Don’t rotate the file if the logs are empty
  • copytruncate – Copy the log file and then empties it. This makes sure that the log file Rails is writing to always exists so you won’t get problems because the file does not actually change. If you don’t use this, you would need to restart your Rails application each time.

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


This ruby on rails tutorial page provides you the following key areas such as ruby , rail , ruby on rails , rail forum , ruby on rails tutorial , ruby tutorial , rails guides , rails tutorial , learn ruby , rails form_for , ruby rails , ruby class , what is ruby on rails , rails installer , ruby online , learn ruby on rails , ruby on rails jobs , rails find_by , install rails , easyrail , rubyonrails , link_to rails , ruby on rails developer , learn ruby the hard way , railscasts , ruby on rails examples , ruby on rails vs php , rails 4 , rails activerecord , rails generate , ruby and rails , ruby on rails download , install ruby on rails , ruby net http , what is rails , ruby app , ruby vs ruby on rails , ruby on rails windows , rails for zombies , ruby on rails book , ruby on rails development , ruby on rails ide , ruby on rails tutorial pdf

Related Searches to rails.logger in ruby on rails