chris finne

Quiet Assets Logging On Rails Webrick

12 Jul 2017

Older Rails versions used to use the Quiet Assets GEM which was then rolled directly into the Rails asset pipeline with

# config/environments/development.rb

config.assets.quiet = true

This switch works with Webrick and the development.log file, but I usually code with Webrick and byebug for debugging, so I have the console open and am always reading the STDOUT stream. The Asset logging stream is NOT silenced from the STDOUT so my console is still hopelessly cluttered.

Ruby monkey-patching to the rescue:

if Rails.env.development? && defined?(::WEBrick)
  # Stop all the /assets/ logs in the webrick stdout
  module WEBrick
    class HTTPServer < ::WEBrick::GenericServer
      def access_log(config, req, res)
        # so assets don't log
      end
    end
  end

end