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 destinationconfig.mongoid.logger.level = Logger::INFO