[ https://issues.apache.org/jira/browse/LOG4J2-330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13770507#comment-13770507 ]
Nick Williams edited comment on LOG4J2-330 at 9/18/13 6:46 AM: --------------------------------------------------------------- **head desk** That was a stupid mistake on my part. It's unfortunate that you weren't able to verify this bug before beta9 was released. I could have gotten it fixed. But it is what it is. The fix will be in 2.0.0.next. was (Author: beamerblvd): **head desk** That was a stupid mistake on my part. It's unfortunate that you weren't able to verify this bug before beta9 was released. I could have gotten it fixed. But it is what it is. The fix will be in 2.0.0.GA. > NoSQLAppender cannot insert log event to MongoDB > ------------------------------------------------ > > Key: LOG4J2-330 > URL: https://issues.apache.org/jira/browse/LOG4J2-330 > Project: Log4j 2 > Issue Type: Bug > Components: Appenders > Affects Versions: 2.0-beta8 > Environment: JDK 1.7, Mongo Driver 2.11.2 > Reporter: Ruslan > Assignee: Nick Williams > > Seems like NoSQLAppender can't insert any log events to Mongo due to lack of > serializer for Level enum. > {quote} > 2013-07-31 18:19:27,831 ERROR An exception occurred processing Appender > databaseAppender java.lang.IllegalArgumentException: can't serialize class > org.apache.logging.log4j.Level > at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:270) > at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174) > at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:120) > at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) > at com.mongodb.OutMessage.putObject(OutMessage.java:289) > at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:239) > at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:204) > at com.mongodb.DBCollection.insert(DBCollection.java:148) > at com.mongodb.DBCollection.insert(DBCollection.java:91) > at > org.apache.logging.log4j.core.appender.db.nosql.mongo.MongoDBConnection.insertObject(MongoDBConnection.java:61) > {quote} > Here is my config > {quote} > <configuration status="WARN"> > <appenders> > <NoSql name="databaseAppender" suppressExceptions="true"> > <MongoDb collectionName="applicationLog" > factoryClassName="com.borsch.DBManager" factoryMethodName="getNewMongoClient" > writeConcernConstant="NONE" username="root" password="qwe"/> > </NoSql> > </appenders> > <loggers> > <root level="error"> > <appender-ref ref="databaseAppender"/> > </root> > </loggers> > </configuration> > {quote} > For now I used following workaround (code is in Scala) > {code} > class LevelBSONEncoder extends org.bson.Transformer { > def transform(o: Any): AnyRef = > o match { case level: org.apache.logging.log4j.Level => new > java.lang.Integer(level.intLevel()) } > } > // which is used like this > org.bson.BSON.addEncodingHook(org.apache.logging.log4j.Level.ERROR.getClass, > new LevelBSONEncoder()) > {code} > I think it should be done in appender. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org