2013-01-19 98 views
0

每個請求我做我的本地服務器上生成的日誌信息的大量類似如下:的Rails 3.2凌亂的日誌

[aa6f821b342dc08800f423e86d24db20] [127.0.0.1] Rendered shared/_footer.html.erb (3.5ms) 
[aa6f821b342dc08800f423e86d24db20] [127.0.0.1] Completed 200 OK in 2684ms (Views: 590.0ms | ActiveRecord: 191.8ms) 
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1] 
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1] 
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1] Started GET "/assets/global.css?body=1" for 127.0.0.1 at 2013-01-18 19:39:22 -0500 
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1] Served asset /global.css - 304 Not Modified (3ms) 
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1] 
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1] 
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1] Started GET "/assets/caEntry.css?body=1" for 127.0.0.1 at 2013-01-18 19:39:22 -0500 
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1] Served asset /caEntry.css - 304 Not Modified (2ms) 
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1] 
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1] 
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1] Started GET "/assets/forms.css?body=1" for 127.0.0.1 at 2013-01-18 19:39:22 -0500 
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1] Served asset /forms.css - 304 Not Modified (2ms) 
[3a807660584a753319c6c19c405b9cce] [127.0.0.1] 
[3a807660584a753319c6c19c405b9cce] [127.0.0.1] 

像知道什麼是負載,而不是有沒有辦法把這些空的消息清理一下?

回答

0

有一種寶石,但我不記得名字......只是把這個變成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