Meditations, Musings and Memorial Stones

AVANIM :: TecHarmony :: View Rails log in script/console

View Rails log in script/console

October 08, 2009 | Comments: 0

This is very helpful, especially for things like debugging generated SQL statements, and it is simple to enable.

Simply find (or create) the .irbrc file in your home directory, and add the following:

# Log to STDOUT if in Rails
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
   require 'logger'
   RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end

Post a comment


(required, but not displayed)

(optional)


(required)