Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.assets.logger not working #4569

Closed
mdi opened this issue Jan 21, 2012 · 6 comments
Closed

config.assets.logger not working #4569

mdi opened this issue Jan 21, 2012 · 6 comments

Comments

@mdi
Copy link

mdi commented Jan 21, 2012

Setting config.assets.logger = false doesn't seem to work as advertised. When set, I still see sprockets asset logging.

@guilleiguaran
Copy link
Member

Can you put an example of your logs?

@mdi
Copy link
Author

mdi commented Jan 21, 2012

Completed 200 OK in 911ms (Views: 408.0ms | ActiveRecord: 105.0ms)


Started GET "/assets/bootstrap.css?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/formtastic-bootstrap.css?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery-ui.css?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery.tagsinput.css?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery.timepicker.css?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/locales/jquery.ui.datepicker-en.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/autocomplete-rails.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/bootstrap-alerts.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/bootstrap-dropdown.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/bootstrap-tabs.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jail.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery.isotope.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery.livequery.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery.tagsinput.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/jquery.timepicker.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/showdown.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/wmd.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/string.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/spin.gif" for 127.0.0.1 at 2012-01-20 23:16:46 -0500


Started GET "/assets/icons.png" for 127.0.0.1 at 2012-01-20 23:16:47 -0500

@mdi
Copy link
Author

mdi commented Jan 21, 2012

Looking closer at the logs, it seems it gets rid of the calls like:

Served asset /jquery.isotope.js - 304 Not Modified (0ms)

But what about the calls like:

Started GET "/assets/jquery.isotope.js?body=1" for 127.0.0.1 at 2012-01-20 23:16:46 -0500

Is that sprockets or something else?

@guilleiguaran
Copy link
Member

The Served asset lines and Compiling lines are logged by Sprockets, the Started GET one are logged by ActionPack. config.assets.logger = false only can be used to silent Sprockets logs.

If you want to silent the request logging you can patch Rails::Rack::Logger in an initializer:

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 

For details about why we won't silent the Started GET one read this: #3795 (comment)

@mdi
Copy link
Author

mdi commented Jan 21, 2012

Cool. Thanks!

@i5ting
Copy link

i5ting commented Sep 20, 2013

3.2.13 not working。。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants