Skip to content
Grant Carthew edited this page Jun 7, 2018 · 3 revisions

Using jq

The jq command line tool is an excellent way of analyzing your log files. If you are logging to file and need to view or query the logs for debugging, this is the tool to use.

Go to the documentation for jq and learn how to use it. Test it out on jq play. Here is a taste:

# Pretty print the log to the console.
jq . app.log

# Filter out just the 'msg' key.
jq .msg app.log

# Filter out just the error logs.
jq 'if .level == "error" then . else empty end' app.log

# Filter out the error logs and just display the error messages.
jq 'if .level == "error" then .data.message else empty end' app.log