How to change log level for MongoDB logs?
Asked Answered
M

2

6

Is there any way to change the default log level for MongoDB ?

There're too many insertion/update entries in the log file, causing it grow way too big.

command used to start mongo:

./bin/mongod --fork --bind_ip 0.0.0.0 --dbpath /data/db/ --logpath /data/log/mongodb/mongod.log --logappend --quiet --logRotate reopen

the log file is filled with:

2018-08-31T11:30:46.831+0800 I COMMAND  [conn564] command eques.$cmd command: insert 

I just need error or more severe level entries.

Mervin answered 31/8, 2018 at 3:43 Comment(0)
B
4

Check the verbosity levels first

db.getLogComponents()

Note : All components not specified explicitly in the configuration have a verbosity level of -1, indicating that they inherit the verbosity level of their parent, if they have one, or the global verbosity level (systemLog.verbosity) if they do not.

Use the db.setLogLevel(<level>, <component>) method to update a single component log level.

For a component, you can specify verbosity level of 0 to 5, or you can specify -1 to inherit the verbosity of the parent.

For example, the following sets the systemLog.component.query.verbosity to its parent verbosity (i.e. default verbosity):

db.setLogLevel(-1, "query")

More info : https://docs.mongodb.com/manual/reference/method/db.setLogLevel/

Browder answered 18/8, 2021 at 0:58 Comment(1)
This function not available in 2.6 version..how to check any idea?Burnell
C
1

The verbosity can be set to 0 overall and every individual component inherits the parent verbosity setting (of 0). That is as low as the verbosity setting goes. To further reduce the logging you can set systemLog.quiet but that is not recommended for production systems because it can make tracking down issues too difficult and it may not address the root cause in any case.

More - https://docs.mongodb.com/manual/reference/configuration-options/

Hope this helps!

Calathus answered 31/8, 2018 at 4:10 Comment(1)
That's sad, I have enabled quite flag, but nothing changed.Mervin

© 2022 - 2024 — McMap. All rights reserved.