jcollum
jcollum

Reputation: 46569

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.

Upvotes: 6

Views: 7415

Answers (3)

Raphael
Raphael

Reputation: 1721

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.

Upvotes: 1

jede
jede

Reputation: 2461

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

Upvotes: 7

Barrie
Barrie

Reputation: 807

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.

Upvotes: 1

Related Questions