<p>I will show you how to enable logging in the MongoDB Java driver and also how to set and change the log level. The <a href="https://mongodb.github.io/mongo-java-driver/">official mongoDB Java driver</a> uses <a href="https://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html">java.util.logging</a> as its default logging framework or sl4j if the latter is present. It can be very useful to enable logging in the MongoDB drivers to trace how the driver is interacting with…
<p><em>I originally published this post on my old blog in 2009. I’ve edited it a little for readability but left the contents unchanged, so it may be out of date and not reflect the current state of the <a href="http://www.pantheios.org/">pantheios</a> library. I also haven’t been using pantheios for logging since about 2010, and have been using <a href="http://www.boost.org/doc/libs/1_55_0/libs/log/doc/html/index.html">Boost.Log</a> instead.</em></p>
<p>I recently ran into a requirements for retrofitting a logging library to an existing project. My first instinct was to throw <a href="http://pantheios.sourceforge.net/">Pantheios</a> at it as I’ve used it before and It Just Worked. Unfortunately in this case, we needed the ability to log to more than two event sinks and it looked like this was getting a little awkward with <a href="http://pantheios.sourceforge.net/">Pantheios</a>, which prompted me to look at <a…