Skip to content

Instantly share code, notes, and snippets.

@harssh-sparkway
Created January 31, 2014 07:18
Show Gist options
  • Save harssh-sparkway/8727820 to your computer and use it in GitHub Desktop.
Save harssh-sparkway/8727820 to your computer and use it in GitHub Desktop.
Rails Logger Tricks
#Rails Logger Tricks
#Here are a few quick tricks for using the Rails logger.
#Save disk space by rotating logs in the config/environments/test.rb and config/environments/development.rb
config.logger = Logger.new(Rails.root.join("log",Rails.env + ".log"),3,5*1024*1024)
#which will rotate the log files every 5 megabytes and leave only the three most recent log files. This will limit the total spaces #used by the logs at 15 megabytes.
#To log to STDOUT while using the console use this trick:
if $0 == "irb"
config.logger = Logger.new(STDOUT)
else
config.logger = Logger.new(Rails.root.join("log",Rails.env + ".log"),3,5*1024*1024)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment