How to set the Rails cache log level separately?

I am using a rather old version of rails, which is 2.3.2 due to the old project.

I set the global log_level for: debug in our rails application. But since we also use Rails.cache, the log file is filled with annoying lines such as: Cache reads: ...
Cache skip: ...

I want to simply suppress them, but not affect other “more useful” information, such as SQL logging.

How to do it?

+5
source share
1 answer

, ( , ) environment.rb, cache_store , :

config.cache_store = ActiveSupport::Cache::MemoryStore.new(:expires_in => 5.minutes)
config.cache_store.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}_cache.log")
config.cache_store.logger.level = Logger::INFO

, , ! : - |

config.cache_store.silence!
+10

All Articles