Mongodb – Why mongodb logs commands in the log file and how to avoid that

loggingmongodb

OS: Windows 10/ Server 2012

Mongodb verison : 3.4.9

I have set the mongod –logPath and –quiet command line parameter

The logs are just growing beyond 100mb and not rotating. Seeing the logs I see lot of entries example:

I COMMAND [conn9] command DBNAME.VERSIONS command: find {

How can I restrict mongodb to log these as I really do not care about the command

Best Answer

To increase the slowms value , follow the below steps:

For Exmple, If you want to increase the slowms vlaue to 500ms

db.setProfilingLevel(1, 500)

It will set the slowms to 500ms and will also turn on the profiling. So to stop the profiling, run the below command.

db.setProfilingLevel(0)

This can also be done by restarting MongoDB with the --slowms option.

Now, the commands will get logged in the log file only when the command takes more than 500ms to execute.