4

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

As they're (uselessly) taking most of the reading space and being lazy to always scroll a little, currently trying to find a way to hide those assets' messages :

(..interesting stuff..) Completed 200 OK in 281ms (Views: 83.9ms | ActiveRecord: 16.7ms)

(..not so interesting stuff..) Started GET "/assets/application.css?body=1" for 127.0.0.1 at Tue Dec 27 13:17:16 +0100 2011
Served asset /application.css - 304 Not Modified (1ms)
(...loads more of useless stuff...)
Community
  • 1
  • 1
Ben
  • 5,030
  • 6
  • 53
  • 94

3 Answers3

4

You can add this inside config/initializers/quiet_assets.rb

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

Hopefully a cleaner option will make it into Rails 3.2

Brian Armstrong
  • 19,707
  • 17
  • 115
  • 144
  • 1
    That was a great solution for rails 3.1; a cleaner option did not made it into rails 3.2 but a nice solution can be found here http://rorguide.blogspot.fr/2012/01/getting-error-undefined-method.html ('useless' backtrace, see at the bottom for the piece of code) – Ben Jun 06 '12 at 09:01
1

Also track this discussion https://github.com/rails/rails/pull/3795

woto
  • 2,893
  • 1
  • 29
  • 24
0

You can do a monkey-patch to make it silent. A solution from a Chinese community:

# inside config/environments/development.rb
YouApp::Application.configure do
  # add this
  config.after_initialize do |app|
    app.assets.logger = Logger.new('/dev/null')
  end
end

# and this
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
Limbo Peng
  • 2,485
  • 19
  • 12