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

前端 未结 3 565
无人共我
无人共我 2021-01-05 15:21

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.

相关标签:
3条回答
  • 2021-01-05 16:00

    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.

    0 讨论(0)
  • 2021-01-05 16:12

    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
    
    0 讨论(0)
  • 2021-01-05 16:18

    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.

    0 讨论(0)
提交回复
热议问题