Reputation: 667
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.
Upvotes: 6
Views: 20133
Reputation: 7693
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/
Upvotes: 4
Reputation: 1503
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!
Upvotes: 1