我想删除插入日志消息的日志输出(org.mongodb.driver.protocol.insert)。我怎么做?
我偶然发现了一些stackoverflow帖子,但它们对我不起作用。我已经尝试在将加载MongoDB驱动程序类的类的类初始化方法中运行这些方法调用:
java.util.logging.Logger.getLogger("org.mongodb.driver").setLevel(java.util.logging.Level.SEVERE);
org.apache.log4j.LogManager.getLogger("org.mongodb.driver.protocol.insert").setLevel(org.apache.log4j.Level.ERROR);
以及在我的类的类初始值设定项中设置以下属性,这些属性将加载MongoDB驱动程序类。
System.setProperty("DEBUG.MONGO", "false");
System.setProperty("DB.TRACE", "false");
并创建log4j.properties
log4j.logger.org.mongodb.driver=ERROR
#log4j.logger.com.mongodb=ERROR <- tried this too even though it should be outdated
log4j.rootLogger=error, stdout
但都无济于事。每次插入控制台时仍然会打印消息:
02:00:32.619 [main] DEBUG org.mongodb.driver.protocol.insert - Inserting 1 documents into namespace x.data on connection [connectionId{localValue:5}] to server x:27017
02:00:32.622 [main] DEBUG org.mongodb.driver.protocol.insert - Insert completed
02:00:32.622 [main] DEBUG org.mongodb.driver.protocol.insert - Inserting 1 documents into namespace x.data on connection [connectionId{localValue:4}] to server x:27017
02:00:32.625 [main] DEBUG org.mongodb.driver.protocol.insert - Insert completed
停止记录这些邮件的正确方法是什么?
MongoDB驱动程序版本3.3.0