Silencing Asset Pipeline Details in Rails Logs

The asset pipeline details can get quite extensive in Rails logging and since the details you are analyzing typically are not related to the loading of assets, you may want to silence them, or prevent them from logging – especially since you can always turn logging back on if you run into asset troubles.

I’ve found three ways to do so:

  1. you can use the Quiet Assets gem

These other two were mentioned on Stack Overflow, but I was not able to get them to work:

  1. you can add this as an initializer in config/initializers/quiet_assets.rb:
if Rails.env.development?
  Rails.application.assets.logger ='/dev/null')
  Rails::Rack::Logger.class_eval do
    def call_with_quiet_assets(env)
      previous_level = Rails.logger.level
      Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
      Rails.logger.level = previous_level
    alias_method_chain :call, :quiet_assets

3.  if you are using Rails 3.2 or above, you can include this setting in config/environments/development.rb:

config.assets.logger = false

Making the Asset Pipeline Less Verbose

I was getting a little overwhelmed by the amount of messages regarding each asset in my development logs, so I wanted to make my logs less verbose.  It was making it more challenging to find the real actions and queries I was trying to analyze.

I found the answer in this post on Stack Overflow.

For some people, adding the initializer code worked, but for me, I went with adding:

config.assets.debug = false

in config/enviroments/development.rb 

and that was sufficient for me.  I’m using Rails 3.1 and I noticed different settings people used in 3.2, so it may also be different if you use 3.2.