getLog
-
getLog
-
getLog
is an administrative command that returns the most recent 1024 loggedmongod
events.getLog
does not read log data from themongod
log file. It instead reads data from a RAM cache of loggedmongod
events. To rungetLog
, use thedb.runCommand( { command } )
method on theadmin
database.The
getLog
command has the following syntax:The possible values for
getLog
are:global
- returns the combined output of all recent log entries.rs
- if themongod
is part of a replica set,getLog
returns recent notices related to replica set activity.startupWarnings
- returns logs that may contain errors or warnings from MongoDB’s log from when the current process started. Ifmongod
started without warnings, this filter may return an empty array.
Returns: A document that contains an array of log events as log
and the number of log events astotalLinesWritten
.
Behavior
Specify *
to getLog
to return a list of available log filters for the mongod
.
getLog
truncates any event that contains more than 512 characters.
Examples
Retrieve Available Log Filters
The following operation returns the available log filters for passing to getLog
The operation returns the following document:
Retrieve Recent Events from Log
The following operation retrieves the most recent global
events for the mongod
The operation returns a document similar to the following:
The highlighted line was truncated, as it exceeded 512 characters.