Reduce Mongo DB logging in version 5.0.6

Dear all,

I have a Node.js application which will query the MongoDB every 5 seconds. When I use the default setting for the MongoDB config, I find that the mongodb log is extremely large. It will create entries for every Node.js query.

So, is there a way to skip the logging? I want to log only error and fatal logs. I have checked the documentation but seems it doesn’t mention how to set this.

Would anyone can provide samples of the config how to eliminate those information log but keep only fatal and error logs?

Thanks a lot

Dear all,

I’m using Mongo DB version 5.0.6 for Windows.

Hi @Paul_Lee2

Logging verbosity can be adjusted as a whole or per component.

Dear Chris,

Thanks for your reply. However, no matter I set the level, from 0 to 5, I still got the following log.

My mongo db config setting:

destination: file
logAppend: false
path: C:\Program Files\MongoDB\Server\5.0\log\mongod.log
quiet: true
verbosity: 5

{"t":{"$date":"2023-08-04T09:11:05.409+08:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn71675","msg":"client metadata","attr":{"remote":"","client":"conn71675","doc":{"driver":{"name":"nodejs","version":"4.5.0"},"os":{"type":"Windows_NT","name":"win32","architecture":"x64","version":"10.0.19045"},"platform":"Node.js v14.17.6, LE (unified)|Node.js v14.17.6, LE (unified)"}}}

{"t":{"$date":"2023-08-04T09:11:05.407+08:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn71674","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"ismaster":true,"helloOk":true,"client":{"driver":{"name":"nodejs","version":"4.5.0"},"os":{"type":"Windows_NT","name":"win32","architecture":"x64","version":"10.0.19045"},"platform":"Node.js v14.17.6, LE (unified)|Node.js v14.17.6, LE (unified)"},"compression":["none"],"loadBalanced":false,"$db":"admin"},"numYields":0,"reslen":775,"locks":{},"remote":"","protocol":"op_query","durationMillis":0}}

My question is how can I remove those log with severity=“Information”, I only want to log severity with fatal or error. I check the document, there is no hints on how to set this.


Setting to 0 will reduce to the lowest verbosity, but you will still get these INFO log lines. There is also the --quiet parameter that may reduce this further.

If size of logs is your concern then logrotating with greater frequency could be appropriate.

1 Like