Created
January 31, 2014 07:18
-
-
Save harssh-sparkway/8727820 to your computer and use it in GitHub Desktop.
Rails Logger Tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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