jq CLI Recipes/Extract log levels

Read a field from each JSON log line.

Section: Logs and Reporting

Extract log levels

bash
bash
cat app.log | jq -r '.level'
Explanation

Works when each log line is a JSON object.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Logs and Reporting
Filter error logs
Return only error-level JSON log lines.
OpenIn sheetbashsame section
Count logs by level
Aggregate log frequency by level.
OpenIn sheetbashsame section
Turn JSON logs into TSV
Extract selected fields into tab-separated text.
OpenIn sheetbashsame section
Build Markdown table rows
Create Markdown-friendly rows from JSON data.
OpenIn sheetbashsame section
Convert env vars into JSON object
Build JSON from shell variables.
OpenIn sheetbashsame section
Pretty-print JSON API response
Format a JSON HTTP response from curl.
OpenIn sheetbash1 tag match