- Reference >
- JavaScript Methods >
- db.setProfilingLevel()
db.setProfilingLevel()¶
-
db.setProfilingLevel(level[, slowms])¶ Parameters: - level – Specifies a profiling level, see list of possible values below.
- slowms – Optionally modify the threshold for the profile to consider a query or operation “slow.”
Modifies the current database profiler level. This allows administrators to capture data regarding performance. The database profiling system can impact performance and can allow the server to write the contents of queries to the log, which might have information security implications for your deployment.
The following profiling levels are available:
Level Setting 0 Off. No profiling. 1 On. Only includes slow operations. 2 On. Includes all operations. Also configure the
slowmsoption to set the threshold for the profiler to consider a query “slow.” Specify this value in milliseconds to override the default.This command provides a wrapper around the database command
profile.mongodwrites the output of the database profiler to thesystem.profilecollection.mongodprints information about queries that take longer than theslowmsto the log even when the database profiler is not active.Note
The database cannot be locked with
db.fsyncLock()while profiling is enabled. You must disable profiling before locking the database withdb.fsyncLock(). Disable profiling usingdb.setProfilingLevel()as follows in themongoshell: