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.
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/