我正在使用Mongo数据库存储Java程序中的信息。我正在使用Eclipse和MongoDB 3.0,我遇到的问题是,只要我的程序与Mongo有任何交互,它就会用JULLogger中的红色文本填充控制台。
我目前没有任何代码可以设置记录器级别,因为我在此处或在线其他地方找到的所有示例都给出了错误:
Logger mongoLogger = Logger.getLogger( "org.mongodb.driver" );
mongoLogger.setLevel(Level.SEVERE);
"The method getLogger(String) is undefined for the type Logger"
Run Code Online (Sandbox Code Playgroud)
这是输出:
Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[127.0.0.1:27017],
mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description
ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, all=[ServerDescription{address=127.0.0.1:27017,
type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Opened connection [connectionId{localValue:1, serverValue:117}] to 127.0.0.1:27017 …Run Code Online (Sandbox Code Playgroud)