Question: How can I find and read the MongoDB system message log files? I’m troubleshooting some issues and need to gather some extra information
Answer: There’s a few different options for identifying and reading the messaging log file . As a first step check the “mongod.conf” file , which has reference to the systemlog file
The default installation for the log file is /var/log/mongodb/mongodb.log but if you don’t find it at this location , them check the mongod.conf file
You’ll see something like :
# where to write logging data. systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log
An alternative method to read 1024 mongod events which are logged is to use the getLog command. Just to clarify – the MongoDB command getLog reads only from RAM cache – the getLog doesn’t read from the mongod Log. Note: The getLog requires administrative privileges otherwise you’ll get an error message
"errmsg" : "not authorized on admin to execute command { getLog: "*", lsid: { id: UUID("xxxxxxxxxxxxxxxxxxxx") }, $clusterTime: { clusterTime: Timestamp(1566284667, 1), signature: { hash: BinData(0, xxxxxxxxxxxxxxxxxxxxx), keyId: xxxxxxxxxxxxxx } }, $db: "admin" }",
"code" : 13,
"codeName" : "Unauthorized",
Author: Jack Vamvas
Leave a Reply