mongo-java-driver 3.0.0 Logging

1,548 views
Skip to first unread message

Brian Stienstra

unread,
May 1, 2015, 10:09:19 AM5/1/15
to mongod...@googlegroups.com
I just upgraded to Java driver 3.0 in my application.  I'm seeing a logging messages from the driver in my logs every 10 seconds:

09:53:05.057 [cluster-ClusterId{value='554385366efc8a1ce8aa1cb7', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Checking status of localhost:27017
09:47:06.689 [cluster-ClusterId{value='55437e9d6efc8a20fc80e14f', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=STANDALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=0.8 ms, state=CONNECTED}]

I'm using Log-back in my application.

I tried setting the log level like this:

Logger mongoLogger = Logger.getLogger( "org.mongodb" );
mongoLogger.setLevel(Level.SEVERE); 

Logger mongoLogger = Logger.getLogger( "org.mongodb" );
mongoLogger.setLevel(Level.SEVERE); 

I've tried to control it in the Logback configuration.

                                     <logger name="org.mongodb.driver.cluster" level="WARN"/>
                                     <logger name="org.mongodb" level="WARN"/>

I cannot seem to figure out how to turn it off.  

Anyone figure out how to control these messages?

Brian

Jeff Yemin

unread,
May 1, 2015, 11:16:48 AM5/1/15
to mongod...@googlegroups.com
As documented here, the 3.0 driver uses SLF4J if it's available on the classpath, otherwise if falls back to JUL.  

If I include logback-classic in my pom.xml, I'm able to control the logging with this logback.xml file:

<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>


<logger name="org.mongodb" level="WARN"/>

    <root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>

</configuration>


Can you confirm that both SLF4J and logback are on your classpath, and that the Logback configuration file is being picked up?


Regards,
Jeff 

Brian Stienstra

unread,
May 1, 2015, 12:56:11 PM5/1/15
to mongod...@googlegroups.com
I changed slf4j from 1.6.4 to 1.7.12  and logback-classic started being able to control mongo-java-driver log messages.  Perhaps it was not compatible with logback-classic version 1.0.13

Thanks for the help.

Brian
Reply all
Reply to author
Forward
0 new messages