Alex Rivera | Logout

Prevent Rails 3.1 (webrick?) from logging assets rendering

Asked 2011-08-26T06:37:34.160
10

Every time I load a page, webrick pollutes its log with lots of assets rendering lines. I want it to render assets, but I don't want it to be logged, because it makes it really difficult to look into what really matters. How do I force it to stop doing that?

Edit
Report

1 Answer

3

There is an open ticket for this https://github.com/rails/rails/issues/2639, when it is closed and you have the lastest and greatest, in config/environments/development.rb add:

config.assets.logger = nil

Until the above issues is resolve, then this will work:

Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
  def before_dispatch_with_quiet_assets(env)
    before_dispatch_without_quiet_assets(env) unless env['PATH_INFO'].index("/assets/") == 0
  end
  alias_method_chain :before_dispatch, :quiet_assets
end

Reference: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?

answered 2012-01-04T08:33:06.943

Your Answer