How can I disable MongoDB log messages in console?
This logging is coming from the Ruby Mongo driver. The default logging level seems to be Logger::DEBUG
. Change it to something higher to disable the debug output:
Mongo::Logger.logger.level = Logger::FATAL
To make the driver log to a logfile instead:
Mongo::Logger.logger = Logger.new('mongo.log')
Mongo::Logger.logger.level = Logger::INFO
Note that if you're using the Mongoid ODM, then you may want to adjust logging there too:
Mongoid.logger = Logger.new('mongoid.log')
Mongoid.logger.level = Logger::INFO
For Rails + Mongoid in application.rb
:
config.mongoid.logger = Logger.new(Rails.root + '/log/mongoid.log', :warn)
# ...or change the logging level without a new file destination
config.mongoid.logger.level = Logger::INFO
Disable Console Logging from MongoDB in Eclipse
Thank you very much Ross for your suggestion:
java.util.logging.Logger.getLogger("org.mongodb.driver").setLevel(java.util.logging.Level.SEVERE);
In fact the correct code was this, so only a minor change:
java.util.logging.Logger.getLogger("org.mongodb.driver").setLevel(Level.SEVERE);
I can confirm that I am not longer receiving any logs from mongo within the console at runtime.
How can I remove the MongoDB message of Java console?
Thank you for all.
This was my solution:
Logger mongoLogger = Logger.getLogger( "org.mongodb.driver" );
mongoLogger.setLevel(Level.SEVERE);
How to disable mongoDB java driver logging?
So this solved this issue:
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
...
static Logger root = (Logger) LoggerFactory
.getLogger(Logger.ROOT_LOGGER_NAME);
static {
root.setLevel(Level.INFO);
}
You may set the Level
to a higher Level
if you wish to hide all the logs.
how to prevent logging on console when connected to mongodb from java?
Thanks to @jyemin
By using MongoDB official documentation link
Logger mongoLogger = Logger.getLogger( "org.mongodb.driver" );
mongoLogger.setLevel(Level.SEVERE);
Now no logs are there in the console.
How to disable node mongodb-native driver connections logging in console
This message is not coming from node.js or the node-mongodb-native driver. It is coming from the mongo daemon.
When Starting mongo simply pass the --quiet option and this message will disapear.
Related Topics
Ruby Working on Array Elements in Groups of Four
Find Out If an Ip Is Within a Range of Ips
Ruby: Most Concise Way to Use an Env Variable If It Exists, Otherwise Use Default Value
Is Require File.Expand_Path(..., _File_) the Best Practice
Disable a Group of Tests in Rspec
Rails Mapping Array of Hashes Onto Single Hash
Finding What Is Common to Two Arrays
How to Get the Number of Days in a Given Month in Ruby, Accounting for Year
If Java People Go to Scala, C# Go to F#, Where Do Ruby People Go for Functional Nirvana
Generating Unique, Hard-To-Guess "Coupon" Codes
How to Remove Carriage Returns with Ruby
When Do We Use the "||=" Operator in Rails? What Is Its Significance
Check Whether a String Contains One of Multiple Substrings
Imagemagick 7 with Rmagick 2.16 on MACos Sierra Can't Find Magickwand.H
Generate Unique Random String with Letters and Numbers in Lower Case
Accessing Config from Application.Rb in Controller (Rails 3)