DATAMONGO-961 - Improve logging message handling in MongoDbUtils.

Added guards to check whether the logging is enabled or not.