Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a Rails app that uses MongoDb on the back. I have these messages that say MONGODB [WARNING] Please note that logging negatively impacts client-side performance. You should set your logging level no lower than :info in production in my logs. OK, I never worried about it but decided to look it up just now.

This page on the mongo site doesn't really discuss logging levels, but it does discuss -v vs -vvvv for verbosity. Is that the same thing as log level? As in -vvvvv is the same as a debug log level and -v is the same as an error log level? The docs are very unclear on this topic.

like image 967
jcollum Avatar asked Jan 09 '12 19:01

jcollum


People also ask

Can I use MongoDB for logging?

Write logs to MongoDB To improve the efficiency of the write operation, you can write multiple logs to MongoDB with a single request. The request is in the following format: db. events.

What is verbosity level in MongoDB?

The verbosity level can range from 0 to 5 : 0 is the MongoDB's default log verbosity level, to include Informational messages. 1 to 5 increases the verbosity level to include Debug messages.


2 Answers

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
like image 80
jede Avatar answered Nov 15 '22 03:11

jede


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.

like image 45
Barrie Avatar answered Nov 15 '22 05:11

Barrie