On this page
setProfilingLevel( level, options )
Parameter Type Description
Configures the profiler level. The following profiler levels are available:
The profiler is off and does not collect any data. This is the default profiler level.
The profiler collects data for operations that take longer than the value of
The profiler collects data for all operations.
document or integer
Optional. Accepts an integer or an options document. If an integer value is passed as the
optionsargument instead of a document, the value is assigned to
slowms. The following options are available:
slowmsDefault: 100Type: integer
The slow operation time threshold, in milliseconds. Operations that run for longer than this threshold are considered slow.
logLevelis set to
0, MongoDB records slow operations to the diagnostic log at a rate determined by
slowOpSampleRate. For MongoDB 3.6 deployments, starting in version 3.6.11, the secondaries of replica sets log all oplog entry messages that take longer than the slow operation threshold to apply regardless of the sample rate.
logLevelsettings, all operations appear in the diagnostic log regardless of their latency with the following exception: the logging of slow oplog entry messages by the secondaries. The secondaries log only the slow oplog entries; increasing the
logLeveldoes not log all oplog entries.
This argument affects the same setting as the configuration file option
sampleRateDefault: 1.0Type: double
The fraction of slow operations that should be profiled.
sampleRateaccepts values between 0 and 1, inclusive.
This argument affects the same setting as the configuration option
Profiling can impact performance and shares settings with the system log. Carefully consider any performance and security implications before configuring and enabling the profiler on a production deployment.
See Profiler Overhead for more information on potential performance degradation.