, free & fully virtual. Register Now, free & fully virtual. Register Now

Changing new log format of MongoDB 4.4.1 to old log format


We have recently started using MongoDB 4.4.1 after using MongoDB 2.4.6 for a while. One of the changes of MongoDB 4.4.1 is the log format being changed to JSON format. This is a problem for us because we have a log monitoring tool that we used when we were using MongoDB 2.4.6 and it does not work for MongoDB 4.4.1 because the log format has changed.

Is there a way to change the new log format of MongoDB 4.4.1 to the old log format by changing the log settings?

Welcome to the community @Hiroki_Harigai!

The only supported server logging format in MongoDB 4.4 deployments is the new JSON structured logging format.

However, a benefit of this format is that you can use standard JSON libraries and utilities like jq (a command-line JSON processor) to parse and manipulate log output. The MongoDB documentation includes some examples of jq usage.

Unfortunately older tools will require updates to support this format, or some transformation of relevant log lines or information.

What log monitoring tool are you using?


Hello Stennie,

Thank you for your reply.

We are using a perl script that we made ourselves to monitor logs.
So we need to fix the perl script to support the new format.

Or do you have any OSS monitoring tools that support the new JSON log format you could recommend?



I don’t have any top of mind recommendations for OSS log-based alerts, but the new JSON format makes integration much easier than the previous bespoke logging. Common performance problems and alerts are usually identified via aggregate metrics from serverStatus and similar commands (see: Cloud Manager: Database Commands Used by Monitoring). I use log-based analysis for diagnostic investigations rather than real-time alerts.

Since you already have a custom script to monitor conditions of interest, I suspect the fastest path would be to update your checks with modern equivalents.

What sort of log message conditions are you alerting on?



Thank you for your reply.

We send an alert if an log output consists of a certain string that might relate to an error.
It seems like the main reason why our monitoring script is not working anymore is because the ctime timestamp format is no longer supported.
We will fix the script so it supports JSON format and the new timestamp format.

Thanks for your support :slight_smile:


1 Like