简体   繁体   中英

How to keep Mongo db java driver logs into a file?

I'm using Mongo db java driver in order to perform some actions on my Mongo db server via my app. when running my jar, the mongo db driver prints his logs to the screen. I would like to stop the printing and keep the logs into a file.

can I do this?

Mongodb Java driver uses slf4j logging API. Therefore you can add a logger that implements slf4j API like Logback and an appropriate logback.xml configuration file logging all events to a log file.

https://mvnrepository.com/artifact/ch.qos.logback/logback-classic/1.2.10

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