Add MongodbLogger settings to database.yml for each environment in which you want to use the MongodbLogger. The MongodbLogger will also
look for a separate mongodb_logger.yml or mongoid.yml (if you are using mongoid) before looking in database.yml.
In the mongodb_logger.yml and mongoid.yml case, the settings should be defined without the 'mongodb_logger' subkey.

Usage

After success instalation of gem, a new MongoDB document (record) will be created for each request on your application,
by default will record the following information: Runtime, IP Address, Request Time, Controller, Method,
Action, Params, Application Name and All messages sent to the logger. The structure of the MongoDB document looks like this:

Beyond that, if you want to add extra information to the base of the document (let's say something like user_id on every request that it's available),
you can just call the Rails.logger.add_metadata method on your logger like so (for example from a before_filter):

# make sure we're using the MongodbLogger in this environment
Rails.logger.add_metadata(user_id:@current_user.id)ifRails.logger.respond_to?(:add_metadata)

In this callback send record without "_id", because logger not wait for insert response from MongoDB.

Disable mongodb_logger

To disable MongodbLogger you can use option disable. But this should be set before rails load (for example in Rails app the top of "config/application.rb"):

MongodbLogger::Base.configuredo|config|config.disable=trueend

or

MongodbLogger::Base.disable=true

Migrate to another size of capped collection

If you need change capper collection size, you should change the "capsize" key in mongodb_config and run this task for migration:

rakemongodb_logger:migrate

Rack Middleware

If you want use MongodbLogger in Rack app which is mounted to your Rails app, you can try to use rack middleware:

useMongodbLogger::RackMiddleware

Rails::Engine

If you want use MongodbLogger with some of Rails::Engine, you can do this (example for Spree):

Spree::BaseController.send:include,MongodbLogger::BaseSpree::Admin::BaseController.send:include,MongodbLogger::Base# for admin

The Front End

To setup web interface in you Rails application, first of all create autoload file in you Rails application

File: you_rails_app/config/initializers/mongodb_logger.rb (example)

require'mongodb_logger/server'# required
# this secure you web interface by basic auth, but you can skip this, if you no need this
MongodbLogger::Server.useRack::Auth::Basicdo|username,password|[username,password]==['admin','password']end

and just mount MongodbLogger::Server in rails routes:

File: you_rails_app/config/routes.rb

mountMongodbLogger::Server.new,:at=>"/mongodb"

Now you can see web interface by url "http://localhost:3000/mongodb"

If you've installed MongodbLogger as a gem and want running the front end without Rails application, you can do it by this command:

mongodb_logger_webconfig.yml

where config.yml is config, similar to config of Rails apps, but without Rails.env. Example:

parameter "collection" should be set, if your set custom for your Rails application or start this front end not for production
enviroment (by default taken "production_log" collection, in Rails application gem generate "#Rails.env_log" collection,
if it is not defined in config).

It's a thin layer around rackup so it's configurable as well:

mongodb_logger_web config.yml -p 8282

Passenger, Unicorn, Thin, etc.

Using Passenger, Unicorn, Thin, etc? MongodbLogger ships with a config.ru you can use. See guide: