How to stop registration in MongoDB Ruby client?
I am connecting to MongoDB using Ruby Driver and I cannot see how to disable logging. Here's the current output of the 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 lines above and above, making it difficult to enter into an IRB session. Here's the code used to create the client connection:
client = Mongo::Client.new('mongodb://127.0.0.1:27017/mydb')
Does anyone know how to turn this off? FWIW, I tried to install verbose=false
in /etc/mongod.conf
and it didn't help.
+3
source to share
1 answer
You can change Mongo logger instance and / or verbosity.
From the docs :
You can use the default logger or install your own. To install your own:
Mongo::Logger.logger = other_logger
For more information on the Logger API and the available levels, see the Ruby Logger documentation .
To change the logger level:
Mongo::Logger.logger.level = Logger::WARN
+2
source to share