It's really simple to integrate MongodbLogger into existing Rails applications.
MongodbLogger allows to store all logs from web clusters into one scalable storage - MongoDB. It's flexible schema allows to search and store any kind of informations from logs.
Web panel allows to filter logs and gets analytics data from logs with help of MapReduce.
Add the following to your Gemfile then refresh your dependencies by executing "bundle install" (or just simple "bundle"):
gem "mongodb_logger"
or install by rubygems
gem install mongodb_logger
Add adapter in Gemfile. Supported mongo and moped (mongoid). For example:
gem "mongo"
gem "bson_ext" # for MRI
or
gem "moped"
Add the following line to your ApplicationController:
include MongodbLogger::Base
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. Example mongodb_logger.yml:
production: database: my_app capsize: <%= 500.megabytes %> host: localhost port: 27017 replica_set: true
To setup web interface in you Rails application, first of all create autoload file in you Rails application (create file in "config/initializers/" directory):
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.use Rack::Auth::Basic do |username, password| [username, password] == ['admin', 'password'] end
and mount web in Rails routes:
mount MongodbLogger::Server.new, :at => "/mongodb"