how do I set the logging level to info for MongoDb? how do I set the logging level to info for MongoDb? mongodb mongodb

how do I set the logging level to info for MongoDb?


I had problems with this in my tests, so I ended up doing the following in my spec_helper.rb:

Mongoid.logger.level = Logger::INFO

However if you are inside of rails you should probably (untested) use this to access the logger instead:

config.mongoid.logger


Logging levels refer to rails logging levels whereas the -v flag refers to verbosity.

Rails automatically sets the logging level higher in production than when in development so you shouldn't have anything to worry about.


If you're using mongoid 2.2 or higher, you can set it in mongoid.yml:

production:  hosts:    ...  database: ...  logger: false

Also, this does have a performance impact. When I turned off mongo logging in production, I saw fewer garbage collections and app instance memory footprints were about 15 megabytes smaller during 30-minute load tests using apachebench.