- Reference >
- Database Commands >
- Diagnostic Commands >
- getLog
getLog¶
-
getLog¶ getLogis an administrative command that returns the most recent 1024 loggedmongodevents.getLogdoes not read log data from themongodlog file. It instead reads data from a RAM cache of loggedmongodevents. To rungetLog, use thedb.runCommand( { command } )method on theadmindatabase.The
getLogcommand has the following syntax:The possible values for
getLogare:global- returns the combined output of all recent log entries.rs- if themongodis part of a replica set,getLogreturns 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. Ifmongodstarted without warnings, this filter may return an empty array.
Returns: A document that contains an array of log events as logand 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.