com.deftlabs.logging.mongo
Class MongoHandler

java.lang.Object
  extended by java.util.logging.Handler
      extended by com.deftlabs.logging.mongo.MongoHandler

public class MongoHandler
extends Handler

The Mongo logger for Java Logging.

Most of this documentation came from the Java API docs.

Configuration: By default each MongoHandler is initialized using the following LogManager configuration properties. If properties are not defined (or have invalid values) then the specified default values are used.

 com.deftlabs.logging.mongo.MongoHandler.level specifies the default level for the Handler (defaults to Level.ALL).
 com.deftlabs.logging.mongo.MongoHandler.filter specifies the name of a Filter class to use (defaults to no Filter).
 com.deftlabs.logging.mongo.MongoHandler.encoding the name of the character set encoding to use (else platform default).
 com.deftlabs.logging.mongo.MongoHandler.mongoUri The connection uri with args - see: http://api.mongodb.org/java/current/com/mongodb/MongoURI.html
 com.deftlabs.logging.mongo.MongoHandler.databaseName The name of the Mongo database (defaults to mongo-java-logging).
 com.deftlabs.logging.mongo.MongoHandler.collectionName The name of the Mongo collection (defaults to log).
 com.deftlabs.logging.mongo.MongoHandler.nodeName The optional name of the node. Otherwise, uses ip address(s).
 com.deftlabs.logging.mongo.MongoHandler.maxQueueSize Set the max queue size. If the queue is full, new messages
 are dropped. This was done to avoid memory issues and application blocking (defualt is 500).
 com.deftlabs.logging.mongo.MongoHandler.closeSleepTime The optional (default is 500 ms) amount to sleep before stopping. This
 allows log messsages in the queue/buffer a chance to be persisted to Mongo. This value is in milliseconds.
 com.deftlabs.logging.mongo.MongoHandler.writerThreadCount The optional config param to increase writer threads (default is 1).


 TODO: Configure rolling, time zone, etc?
 


Constructor Summary
MongoHandler()
           
 
Method Summary
 void close()
          Stop the thread.
 void flush()
           
 void publish(LogRecord pRcd)
           
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MongoHandler

public MongoHandler()
             throws Exception
Throws:
Exception
Method Detail

publish

public void publish(LogRecord pRcd)
Specified by:
publish in class Handler

flush

public void flush()
Specified by:
flush in class Handler

close

public void close()
Stop the thread.

Specified by:
close in class Handler