- Reference >
mongo
Shell Methods >- Database Methods >
- db.setProfilingLevel()
db.setProfilingLevel()¶
On this page
Definition¶
-
db.
setProfilingLevel
(level, slowms)¶ Modifies the current database profiler level used by the database profiling system to capture data about performance. The method provides a wrapper around the database command
profile
.Parameter Type Description level
integer Specifies a profiling level, which is either 0
for no profiling,1
for only slow operations, or2
for all operations.slowms
integer Optional. Sets the threshold in milliseconds for the profile to consider a query or operation to be slow. The level chosen can affect performance. It also can allow the server to write the contents of queries to the log, which might have information security implications for your deployment.
Configure the
slowOpThresholdMs
option to set the threshold for the profiler to consider a query “slow.” Specify this value in milliseconds to override the default, 100 ms.mongod
writes the output of the database profiler to thesystem.profile
collection.mongod
prints information about queries that take longer than theslowOpThresholdMs
to the log even when the database profiler is not active.