7

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.

3 Answers 3

7

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 
Sign up to request clarification or add additional context in comments.

2 Comments

This was exactly my problem, I had log messages dumping to stdout when running rspec with mongoid + sinatra. Thanks!
Here's the link to the documentation for this
1

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.

4 Comments

I'm not sure that's it -- I updated the OP. The message specifically states that its from MONGODB and there's a lot of Mongo messages in my log like MONGODB the_database['users'].find({:deleted_at=>nil, :deleted=>nil}). I wonder if this is coming from Mongoid.
It looks like this is coming from the Mongo ruby driver: api.mongodb.org/ruby/current/Mongo/Logging.html# (in the source).
Ok is this in the production or development?
@TylerBrock I think the answer to my question is: don't bother with mongodb for this warning message, the message is unclear, just worry about the logging level in the app.
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.