Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Rails 3.1 (webrick?) from logging assets rendering

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?

like image 885
snitko Avatar asked Aug 26 '11 06:08

snitko


2 Answers

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?

like image 192
Matt Smith Avatar answered Nov 04 '22 23:11

Matt Smith


Add gem 'quiet_assets', :group => :developmentto your Gemfile. See https://github.com/evrone/quiet_assets .

like image 43
lacco Avatar answered Nov 04 '22 23:11

lacco