简体   繁体   中英

Set logging level for mongodb java driver 3.0

I'm including the mongo java 3.0 driver in a plugin for an application that uses log4j2. I can't modify the log4j2.xml file, but I need to be able to set the logging level for the mongo driver.

This would have worked if it was using the native java logger:

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

But this won't affect log4j2.

I don't want to affect levels for all loggers, just the mongo one.

如果已在配置中命名了Log4j2记录器,则可以使用log4j2 JMX界面来设置log4j2记录器的日志级别。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM