This version will reach end of life on Feb 2018. To upgrade, go to the Learn more about upgrading your version of MongoDB.



The getLog command returns a document with a log array that contains recent messages from the mongod process log. The getLog command has the following syntax:

{ getLog: <log> }

Replace <log> with one of the following values:

  • global - returns the combined output of all recent log entries.
  • rs - if the mongod is part of a replica set, getLog will return recent notices related to replica set activity.
  • startupWarnings - will return logs that may contain errors or warnings from MongoDB’s log from when the current process started. If mongod started without warnings, this filter may return an empty array.

You may also specify an asterisk (e.g. *) as the <log> value to return a list of available log filters. The following interaction from the mongo shell connected to a replica set:

db.adminCommand({getLog: "*" })
{ "names" : [ "global", "rs", "startupWarnings" ], "ok" : 1 }

getLog returns events from a RAM cache of the mongod events and does not read log data from the log file.

←   whatsmyuri hostInfo  →