Subscribed unsubscribe Subscribe Subscribe

to Thin from WEBrick

Whenever rails gets http access, it's too loud displaying that
"WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true" on rails's log.

One of Rails-Core's members says "ya, it's fine. Need to clean it up, but nothing is being hurt.", so it isn't problem about displaying this WARN itself.
http://stackoverflow.com/questions/7082364/what-does-warn-could-not-determine-content-length-of-response-body-mean-and-h


There are some kind of way getting rid of this message.
I chose to shift Thin for WEBrick.

I added to GemFile as follows:

group :development do
  gem 'thin'
end


Speaking of cleaning rails's log.
I made quiet_assets.rb on app/config/initializers/
I added the following

Rails.application.assets.logger = Logger.new('/dev/null') 
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

get the silence :3


Ruby on Rails 3 アプリケーションプログラミング