Clean and Fast HttpLog GEM Configuration
HttpLog is a super useful GEM that I use in many of my Rails projects to visualize the HTTP requests made by the code and debug issues.
A good configuration to use with its last version (v0.99) is the following
HttpLog.configure do |config| # Enable logging in Prod Console and everywhere in Dev and Test. Also enable if environment variable is set. config.enabled = not(Rails.env.production?) || ENV.has_key?('HTTPLOG_URL_WHITELIST_PATTERN') || defined?(Rails::Console) # Assign minimum log severity to show entries in logs config.severity = Rails.logger.level # Tweak which parts of the HTTP cycle to log... config.log_connect = false config.log_request = true config.log_headers = true config.log_data = true config.log_status = true config.log_response = true config.log_benchmark = true config.compact_log = false # Log everything if environment variable is not specified config.url_whitelist_pattern = ENV['HTTPLOG_URL_WHITELIST_PATTERN'] || /.*/ config.url_blacklist_pattern = nil end
I recommend to put this in your config/initializers/01_httplog.rb. Make sure (e.g., with 01_) that it is one of the first initializers so you don't pollute your logs during deployment and server initialization.
In production HttpLog will be disable by default to save resources. To see all the connection logs for a specified host just set the environment variable HTTPLOG_URL_WHITELIST_PATTERN and restart your server.














