How to ignore Rails 3 assets from log [duplicate]
-
28-10-2019 - |
Question
Possible Duplicate:
How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
is possible to hack logger in Rails3 to ignore requests for assets?
It is maddness to find something in log, when it is full of
Started GET "/assets/tiscali.png" for 127.0.0.1 at 2011-09-09 19:59:45 +0200
Served asset /tiscali.png - 304 Not Modified (0ms)
Thanks!
Solution
Apparently the issue is still open as of 02 Nov 2011.
A workaround solution is available in a similar question: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
OTHER TIPS
I think this could help https://github.com/evrone/quiet_assets
Deprecation
As of
sprockets-rails
version3.1.0
, used in current versions of rails, this gem is deprecated.The asset pipeline now supports a
quiet
option which suppresses output of asset requests:# config/environments/development.rb config.assets.quiet = true
Relevant PR: https://github.com/rails/sprockets-rails/pull/355
Info
Quiet Assets turns off the Rails asset pipeline log. This means that it suppresses messages in your development log such as:
Started GET "/assets/application.js" for 127.0.0.1 at 2015-01-28 13:35:34 +0300 Served asset /application.js - 304 Not Modified (8ms)
Support Ruby on Rails >= 3.1...
Usage
Simply installing Quiet Assets will suppress the log messages automatically. However, if you wish to temporarily re-enable the logging of the asset pipeline messages, place the following in your
config/application.rb
file:config.quiet_assets = false
If you need to suppress output for other paths you can do so by specifying:
config.quiet_assets_paths << '/silent/'
How about an invert selection?
tail -f log/development.log | grep -v asset
This basically outputs everything except for the lines that contain the word "asset".
Rails 3.2:
create a initializer with the content:
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'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
end
From here: https://github.com/rails/rails/issues/2639