logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nick Williams (JIRA)" <j...@apache.org>
Subject [jira] [Reopened] (LOG4J2-330) NoSQLAppender cannot insert log event to MongoDB
Date Wed, 18 Sep 2013 06:46:53 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-330?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Nick Williams reopened LOG4J2-330:
----------------------------------

    
> 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
>             Fix For: 2.0-beta9
>
>
> 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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message