In this post, we will learn to enable logging MongoDB queries in Java. For this example, we need a MongoDB driver for Java.
To display the query in the log we need to set the
org.mongodb.driver level to debug.
- If you are using Spring Boot project and want to log MongoDB query then you can use the following in your
- If you are using a standalone Java application and using Logback for logging then you can use the following in your
<logger name="org.mongodb.driver" level="debug"></logger>
Leave a Reply