forked from log4mongo/log4mongo-java
-
Notifications
You must be signed in to change notification settings - Fork 1
log4j appender to MongoDB database
License
znbailey/log4mongo-java
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Description ----------- This library provides Log4J Appenders [1] that write log events to the MongoDB document oriented database [2]. MongoDbAppender - Stores a BSONified version of the Log4J LoggingEvent MongoDbPatternLayoutAppender - Uses standard Log4J pattern layout, parser and converter classes to store a log message as a custom-formatted document Author ------ Peter Monks ([email protected]) Contributors ------ Jozef Sevcik ([email protected]) Robert Stewart ([email protected]) Pre-requisites -------------- JDK 1.6+ MongoDB Server v1.0+ (tested with 1.2.1, 1.4.x) (required for unit tests) MongoDB Java Driver v1.0+ (tested with 2.0) Log4J 1.2+ (tested with 1.2.16 - note: won't work on earlier versions due to log4j API changes) Installation / Configuration ---------------------------- 1. Start a local MongoDB server running on the default port - this is required for the unit tests: mongod -dbpath ./mongodata 2. Build the JAR file using Maven2 mvn clean package 3. Deploy the target/log4mongo-java-x.y.jar file, along with the Log4J and MongoDB Java Driver JARs, into the classpath of your Java application 4. Configure log4j as usual, referring to the log4j.properties.sample file for the specific configuration properties the appender supports Todos ----- * Add unit tests * connection failures * Clean up BSONification code - currently it's functional but skanky. Consider using daybreak for this [4]. Notes on Date handling ----- MongoDB (actually BSON) supports datetimes as a native data type [5] and all drivers are supposed to handle conversion from client-native date type (java.util.Date in Java) to BSON representation of date in miliseconds since the Unix epoch. However, MongoDB built-in console (bin/mongo) does represent dates formatted, even the dates were saved in native data type, which may be confusing [6]. See testTimestampStoredNatively in tests (TestMongoDbAppender.java) if you want to get an idea. References ---------- [1] http://logging.apache.org/log4j/1.2/index.html [2] http://www.mongodb.org/ [3] http://github.com/mongodb/mongo-java-driver/downloads [4] http://github.com/maxaf/daybreak [5] http://bsonspec.org/#/specification [6] http://groups.google.com/group/mongodb-user/browse_thread/thread/e59cbc8c9ba30411/af061b4bdbce5287
About
log4j appender to MongoDB database
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- Java 100.0%