Help Docs

MongoDB Logs

MongoDB logs contain critical log related information that can be used to obtain essential insights by splitting them into associated fields such as date & time, log level, component, context, and message. Site24x7 AppLogs is a log management product that facilitates simple log management by pooling all your logs in one single interface. Site24x7 AppLogs natively supports MongoDB along with other critical applications.  Learn more about log management with Site24x7

Getting started

  1. Log in to your Site24x7 account.
  2. Download and install the Site24x7 Server Monitoring agent (Windows | Linux). 
  3. Go to Admin > AppLogs > Log Profile and Add Log Profile.

Logs file path

Each application writes logs in different folders and files. By default, MongoDB logs are sourced from the below-mentioned folder path for the respective Operating System. If you have logs in a different folder, you can mention it under the File Path to source them from that particular folder while creating a log profile.

Linux icon
:
/var/log/mongodb/*.log
Windows icon
:
C:\mongodb*\logs\*.log*
 
 
C:\Program Files\mongodb*\logs\*.log*

Note

Starting with MongoDB 4.4, all log output is in JSON format, consisting of key-value pairs. In earlier versions, the log output was in plain text. Please find the supported log patterns for both cases below.

For MongoDB version 4.4 or above

Log pattern
This is the default pattern defined by Site24x7 for parsing MongoDB logs for version starting 4.4.

json $t.ESC($)date as Datetime:date:yyyy-MM-dd'T'HH:mm:ss.SSSX$ $s as Severity$ $c as Component$ $id$ $ctx as Context$ $msg as Message$ $attr as Attributes:json-object$

Sample log
{"t":{"$date":"2020-05-01T15:16:17.180+00:00"},"s":"I", "c":"NETWORK", "id":12345, "ctx":"listener", "msg":"Listening on","attr":{"address":"127.0.0.1"}}

This log is separated into fields, each of which will take its respective value, and is then uploaded to Site24x7.

For MongoDB version below 4.4

Log pattern
This is the default pattern defined by Site24x7 for parsing MongoDB logs for versions below 4.4.

$DateTime:date:yyyy-MM-dd'T'HH:mm:ss.SSSX$ $Severity$ $Component$ [$Context$] $Message

Sample log
2017-06-07T12:22:33.456-700 I NETWORK [initandlisten] waiting

This log is separated into fields, each of which will take its respective value, and is then uploaded to Site24x7.

Field name Field value
DateTime 2017-06-07T12:22:33.456-700 
Severity I
Component NETWORK
Context initandlisten
Message waiting

Was this document helpful?

Would you like to help us improve our documents? Tell us what you think we could do better.


We're sorry to hear that you're not satisfied with the document. We'd love to learn what we could do to improve the experience.


Thanks for taking the time to share your feedback. We'll use your feedback to improve our online help resources.

Shortlink has been copied!