Rails logging – config.log_level has no effect

Curiously adding config.log_level = :debug to environment.rb appears to have no effect on the logging performed by ActiveRecord. To get to see the detailed logging and benchmarking of your database queries in production mode you need to place this after the Rails::Initializer.run block in environment.rb:

ActiveRecord::Base.logger.level = Logger::DEBUG

One thought on “Rails logging – config.log_level has no effect

  1. Depending on how much logging is done, you may also need to add the following to environment.rb. ActiveRecord::Base.logger.auto_flushing=trueI’ve found this to be the case when I wanted logging from "rake db:migrate RAILS_ENV=production". My sql statements did not contain enough characters to make the ActiveSupport::BufferedLogger flush itself.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s