Log HTTP requests to MongoDB for debugging and access them via the web
CSS Ruby HTML JavaScript
Latest commit ff11889 Oct 4, 2015 @ahawkins Merge pull request #1 from orthographic-pedant/spell_check/against
Fixed typographical error, changed aganist to against in README.
Failed to load latest commit information.
app Remove pointless JS Feb 26, 2013
config HttpLogger -> HttpLog Jan 19, 2012
lib Bump patch Feb 26, 2013
script HttpLogger -> HttpLog Jan 19, 2012
test Fix precompile test Feb 26, 2013
.gitignore Remove Gemfile.lock Mar 19, 2012
Gemfile Remove pointless JS Feb 26, 2013
MIT-LICENSE Initial commit Jan 18, 2012
Rakefile HttpLogger -> HttpLog Jan 19, 2012



Build Status Gem Version Code Climate Dependency Status

Logs all requests made to your application in a search format to MongoDB. This gem includes a middleware to log rack requests to MongodB. It also adds a header to every response indicating an id that can be used to retrieve that request. You can combine this header and the one's added by rails to track the conversation applications are having with your application.


This gem using Mongoid to store the models. Once you install the gem, run the mongoid config generator to setup the connection.

gem 'http_log'

bundle install

bundle exec rails g mongoid:config # if you don't already have one

Example of What is Logged

  "raw_post":"{\"foo\": \"bar\"}",


You may also filter out specific requests. Requests to /assets are filters by default. You can filter requests using three different methods:

  1. Symbols (treated as file extensions)
  2. Regex (matched against the full URL)
  3. Blocks/Procs/Lambda/Things that respond_to? :call

Filters are used to exclude requests. So, if a filter returns true then that request will not be logged.

Here are some examples.

# Using Symbols
HttpLog.filters << :jpg

# Using Regex
HttpLog.filters << /private/

# Using Blocks/Procs/Lambdas/Things that resond_to? :call
# req is ActionDispatch::Request with some sugar
HttpLog.filter do |req|
  req.env # perhaps access the rack request stuff
  true if my_conditions_are_met

Adding More Log Information

You can add has many callbacks as you'd like. They are executed inside the middleware after the initial log is instantiated. Callbacks are ran, then the log is persisted.

Let's say you want to add some more headers of your own:

# config/initializers/http_log.rb
# req is an ActionDispatch::Request
# log is the HttpLog::Request instance

HttpLog.with_request |log, req|
  log.headers['Custom-Foo'] = 'bar'

You may also add your own fields by reopneing the class and using the Mongoid APi.

# config/initializers/http_log.rb
class HttpLog::Request
  field :developer_api_key, :type => String

HttpLog.with_request |log, req|
  log.developer_api_key = req.parameters['developer_api_key']