No commit activity in last 3 years
No release in over 3 years
Simple implementation of a logging appender for Tim Pease's Logging framework using Mongoid.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

>= 1.8.0
>= 3.0.0
 Project Readme

Gem Version Code Climate

MongoidAppender

MongoidAppender is a simple implementation of a standard Logging::Appender for Tim Pease's Logging framework using Mongoid, useful for writing log messages into MongoDB. MongoidAppender has been tested with both Mongoid 3.x and 4.0.

Installation

Add this line to your application's Gemfile:

gem 'mongoid_appender'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mongoid_appender

Usage

Configure MongoidAppender as you would a normal Logging::Appender. For example, to configure your root logger to output all messages to stdout but only write :warn messages and above to MongoDB, you can use the following code:

require 'logging'
require 'mongoid'

# Some code to set up Mongoid here...

Logging.logger.root.add_appenders(
    Logging.appenders.stdout,
	MongoidAppender.new('mongoid', :level => :warn)
)

By default, MongoidAppender will write log documents into a MongoDB collection named logs. Every document has the following fields:

  • level - The event level (debug, info, warn, error, etc.)
  • logger - The name of the logger
  • message - The log message
  • exception - The log exception (if any)
  • backtrace - The log backtrace (if any)

Simple!