How to read MongoDB system log file

20 August,2019 by Jack Vamvas

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",

 

Read MongoDB cheatsheet for more MongoDB commands 


Author: Jack Vamvas (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to read MongoDB system log file


dba-ninja.com