I have this little test script:
require \'mongo\'
mongo_client = Mongo::Client.new([\'127.0.0.1:27017\'], :database => \'test\')
mongo_client[:collection
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
To disable the debug output for Ruby Mongo Driver(mongoid) we can add it specific environment file as
config.mongoid.logger.level = Logger::INFO