views:

1232

answers:

1

With the new caching options in Rails 2.1 i get nice entires in my log along the lines of

Cached fragment hit: views/homepage (0.16549)

However they are logged at the :debug level, which is the same level as the SQL output. I want to be able to disable the SQL output, and still see the cache info. How can I do this

+9  A: 

well you could instanciate a specific logger for ActiveRecord and set it's log level to :info while leaving the default logger at debug ...

ActiveRecord::Base.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}_database.log")
ActiveRecord::Base.logger.level = Logger::INFO # should set the log_level to info for you

from http://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging

or you could reopen AbstractAdapter and override the log(sql,name) method so it does nothing

http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/AbstractAdapter.html#M001242

Jean
Thats cool, what is the syntax to set the new logger into info? `ActiveRecord::Base.logger.level = :info` causes runtime errors
Laurie Young