Reputation: 402
I'm connecting to MongoDB using the Ruby Driver and I don't see how to turn off the logging. Here's the current output from an IRB session:
D, [2015-06-06T11:01:05.622513 #30526] DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 0.7546ms
D, [2015-06-06T11:01:15.623716 #30526] DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 0.7083ms
....
It repeats the lines above over and over, which makes it very difficult to type in the IRB session. Here's the code used to create the client connection:
client = Mongo::Client.new('mongodb://127.0.0.1:27017/mydb')
Anyone know how to turn that off? FWIW, I tried setting verbose=false
in /etc/mongod.conf
and that did not help.
Upvotes: 2
Views: 826
Reputation: 6478
You can change Mongo's logger instance and/or verbosity.
From the docs:
You can either use the default driver logger or set your own. To set your own:
Mongo::Logger.logger = other_logger
Please see the Ruby Logger documentation for more information on the default logger API and available levels.
To change the logger level:
Mongo::Logger.logger.level = Logger::WARN
Upvotes: 1