- Reference >
- Database Commands >
- Diagnostic Commands >
- getLog
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
.
Starting in MongoDB 4.2, getLog
truncates any event that
contains more than 1024 characters. In earlier versions,
getLog
truncates after 512 characters.