- Reference >
- Log Messages
Log Messages¶
On this page
Changed in version 3.0.
Starting in MongoDB 3.0, MongoDB includes the severity level and the component associated with each log message. The log messages have the form:
<timestamp> <severity> <component> [<context>] <message>
For example:
2014-11-03T18:28:32.450-0500 I NETWORK [initandlisten] waiting for connections on port 27017
Timestamp¶
The default format for the <timestamp> is iso8601-local. To modify the timestamp format, use the --timeStampFormat runtime option or the systemLog.timeStampFormat setting.
Severity Levels¶
The following table lists the severity levels associated with each log message:
Level | Description |
---|---|
F | Fatal |
E | Error |
W | Warning |
I | Informational, for Verbosity Level of 0 |
D | Debug, for All Verbosity Levels > 0 |
You can specify the verbosity level of various components to determine the amount of Informational and Debug messages MongoDB outputs.
To set verbosity levels, see Configure Log Verbosity Levels.
Components¶
Log messages now include components, providing functional categorization of the messages:
- ACCESS¶
Messages related to access control, such as authentication. To specify the log level for ACCESS components, use the systemLog.component.accessControl.verbosity setting.
- COMMAND¶
Messages related to database commands, such as count. To specify the log level for COMMAND components, use the systemLog.component.command.verbosity setting.
- CONTROL¶
Messages related to control activities, such as initialization. To specify the log level for CONTROL components, use the systemLog.component.control.verbosity setting.
- GEO¶
Messages related to the parsing of geospatial shapes, such as verifying the GeoJSON shapes. To specify the log level for GEO components, set the systemLog.component.geo.verbosity parameter.
- INDEX¶
Messages related to indexing operations, such as creating indexes. To specify the log level for INDEX components, set the systemLog.component.index.verbosity parameter.
- NETWORK¶
Messages related to network activities, such as accepting connections. To specify the log level for NETWORK components, set the systemLog.component.network.verbosity parameter.
- QUERY¶
Messages related to queries, including query planner activities. To specify the log level for QUERY components, set the systemLog.component.query.verbosity parameter.
- REPL¶
Messages related to replica sets, such as initial sync and heartbeats. To specify the log level for REPL components, set the systemLog.component.replication.verbosity parameter.
- SHARDING¶
Messages related to sharding activities, such as the startup of the mongos. To specify the log level for SHARDING components, use the systemLog.component.sharding.verbosity setting.
- STORAGE¶
Messages related to storage activities, such as processes involved in the fsync command. To specify the log level for STORAGE components, use the systemLog.component.storage.verbosity setting.
MongoDB distinguishes JOURNAL components from STORAGE components; however, STORAGE is the parent of JOURNAL. As such, if systemLog.component.storage.journal.verbosity setting is unset, MongoDB uses the STORAGE verbosity level for JOURNAL components
- JOURNAL¶
Messages related specifically to journaling activities. To specify the log level for JOURNAL components, use the systemLog.component.storage.journal.verbosity setting.
MongoDB distinguishes JOURNAL components from STORAGE components; however, STORAGE is the parent of JOURNAL. As such, if systemLog.component.storage.journal.verbosity is unset, MongoDB uses the STORAGE verbosity level for the JOURNAL components as well.
- WRITE¶
Messages related to write operations, such as update commands. To specify the log level for WRITE components, use the systemLog.component.write.verbosity setting.
- -¶
Messages not associated with a named component. Unnamed components have the default log level specified in the systemLog.verbosity setting. The systemLog.verbosity setting is the default setting for both named and unnamed components.
Verbosity Levels¶
View Current Log Verbosity Level¶
To view the current verbosity levels, use the db.getLogComponents() method.
Configure Log Verbosity Levels¶
You can configure the verbosity level using: the systemLog.verbosity and systemLog.component.<name>.verbosity settings, the logComponentVerbosity parameter; the db.setLogLevel() method.
systemLog Verbosity Settings¶
To configure the default log level for all components, use the systemLog.verbosity setting. To configure the level of specific components, use the systemLog.component.<name>.verbosity settings.
For example, the following configuration sets the systemLog.verbosity to 1, the systemLog.component.query.verbosity to 2, the systemLog.component.storage.verbosity to 2, and the systemLog.component.storage.journal.verbosity to 1:
systemLog:
verbosity: 1
component:
query:
verbosity: 2
storage:
verbosity: 2
journal:
verbosity: 1
All components not specified in the configuration have the systemLog.verbosity of 1.
logComponentVerbosity Parameter¶
To set the logComponentVerbosity parameter, pass a document with the verbosity settings to change.
For example, the following sets the default verbosity level to 1, the query to 2, the storage to 2, and the storage.journal to 1.
use admin
db.runCommand( {
setParameter: 1,
logComponentVerbosity: {
verbosity: 1,
query: {
verbosity: 2
},
storage: {
verbosity: 2,
journal: {
verbosity: 1
}
}
}
} )
db.setLogLevel()¶
Use the db.setLogLevel() 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")
Thank you for your feedback!
We're sorry! You can Report a Problem to help us improve this page.