Laurie Young
Laurie Young

Reputation: 138434

Rails Caching Log Level

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

Upvotes: 7

Views: 5225

Answers (1)

Jean
Jean

Reputation: 21595

well you could instantiate 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

Upvotes: 11

Related Questions