How to prettify the JSON log?

How to prettify the JSON logging ?

Screenshot:

Screenshot 2020-09-20 at 9.19.30 PM

I want to prettify this.

On Unix systems you can try this

cat mongod.log | tail -3 | jq

1 Like

Let me check :slightly_smiling_face:

Not working.

anish@Anishs-MacBook-Pro ~ % cat /Users/anish/mongodata/logs/mongod.log | tail -3 | jq

zsh: command not found: jq

You have to install jq:

brew install jq
1 Like

You need to install jq package (a command line JSON processor) using brew.

Steps to install jq package :

  • Open Terminal
  • Execute this command to install homebrew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
  • If you are prompt to enter password, then enter your system password.
  • After above command finishes installation, then run this command : brew install jq

Execute this command : cat mongod.log | jq

1 Like