7 Tools for Searching Logs from the Command Line
Seven tools for searching logs from the command line, from ripgrep and jq to lnav and angle-grinder.
On this page
Key takeaways
- The command line is the fastest path to a one-off log question.
- Small tools compose into a pipeline that answers almost anything.
- Structured data turns text search into field-precise queries.
- A saved command becomes a repeatable search for next time.
Quick comparison
| Tool | Best for | Starting price | Free plan |
|---|---|---|---|
| ripgrep | Fast text search | Not included | Not included |
| jq | Parsing structured lines | Not included | Not included |
| jaq | Lightweight JSON processing | Not included | Not included |
| lnav | Browsing merged logs | Not included | Not included |
| Angle Grinder | Aggregating large logs | Not included | Not included |
| Graylog | Central search with API | Not included | Not included |
| Loki | Label-based log queries | Not included | Not included |
The best tools for searching logs from the command line
1. ripgrep
- Official site: https://github.com/BurntSushi/ripgrep
- Best for: Fast text search
- Starting price: Not included
- Free plan: Not included
- Pros: Very fast; smart defaults
- Cons: Plain text focus
ripgrep searches text across files faster than the classic grep, with sensible defaults and good output. It skips binary files and respects ignore rules, so it is comfortable to run on a large log directory. The speed makes an interactive search feel immediate.
For a quick question such as which files contain an error string, ripgrep is the natural first tool. Its output is easy to pipe into the next step of a longer pipeline.
2. jq
- Official site: https://jqlang.org/
- Best for: Parsing structured lines
- Starting price: Not included
- Free plan: Not included
- Pros: Precise; scriptable
- Cons: JSON only
jq parses JSON and extracts, filters, and transforms fields with a compact language. When logs are structured, jq turns raw lines into the exact fields a search needs. A single expression can select records by field and print a clean summary.
For structured logs, jq replaces fuzzy text matching with precise queries. It is the difference between searching for a string and asking for every record where the status field is a specific value. The result is smaller and the answer is exact.
3. jaq
- Official site: https://github.com/01mf02/jaq
- Best for: Lightweight JSON processing
- Starting price: Not included
- Free plan: Not included
- Pros: Small; fast
- Cons: Smaller feature set
jaq is a lightweight implementation of the jq language, focused on speed and a small footprint. It covers the common query cases without the full feature surface. The smaller binary suits environments where resources matter.
For teams that like jq but want a lighter tool, jaq handles the everyday parsing and filtering. The same query style works, so the learning transfers directly.
4. lnav
- Official site: https://lnav.org/
- Best for: Browsing merged logs
- Starting price: Not included
- Free plan: Not included
- Pros: Merges and sorts; filters
- Cons: Interactive terminal tool
lnav opens log files in an interactive view, merges several files into one timeline, and filters entries by pattern or field. It understands common formats and makes moving through a large log pleasant. The timeline view keeps related events together.
For an investigation where the goal is to read around a problem rather than extract a single value, lnav is the tool of choice. It turns a directory of files into one browsable stream.
5. Angle Grinder
- Official site: https://github.com/rcoh/angle-grinder
- Best for: Aggregating large logs
- Starting price: Not included
- Free plan: Not included
- Pros: Fast summaries; simple syntax
- Cons: Summary focused
Angle Grinder processes large log files and produces counts, top lists, and summaries. It answers the question of what dominates a log without printing millions of lines. The syntax is short and quick to write.
For a high-volume log, the useful answer is usually a summary, and Angle Grinder returns it fast. It is the command-line version of the aggregation a dashboard would do.
6. Graylog
- Official site: https://graylog.org/
- Best for: Central search with API
- Starting price: Not included
- Free plan: Not included
- Pros: Search API; central store
- Cons: Needs infrastructure
Graylog indexes logs centrally and exposes a search API that the command line can query. A script can run the same searches the web interface offers and pull results into the terminal. The central store keeps the history searchable.
For a team that already centralizes logs, the command line becomes another client for the same store. Scripts and one-off queries share one source of truth.
7. Loki
- Official site: https://grafana.com/oss/loki/
- Best for: Label-based log queries
- Starting price: Not included
- Free plan: Not included
- Pros: CLI client; cheap storage
- Cons: No full-text index
Loki stores logs by labels and offers a command-line client for querying them. A script can query by service and time and filter by content pattern. The low storage cost keeps the history long enough to be worth querying.
For teams that use Loki as their store, the CLI brings the same queries to the terminal. Scripts and manual searches share the label model, so the habits transfer.
How we chose
We looked for tools that answer a log question quickly from a terminal, since a one-off search should not need a platform login. The list spans text search, structured parsing, and central-store clients so a team can match the tool to its data. Each entry is small enough to compose with the others in a pipeline.
We favored tools that handle structure, because field-precise queries beat text matching as soon as logs have a schema. A tool such as jq turns a fuzzy search into an exact one. That precision is what keeps the results trustworthy.
We also valued composability, since the power of the command line is chaining small tools. A pipeline of ripgrep, jq, and a summarizer answers questions no single tool is built for. The best habit is to save those pipelines as scripts for next time.
FAQ
When should I search logs from the command line?
For quick, one-off questions where opening a platform is slower than typing a command. It is also the right place for scripting and automation. Repeated or team-wide queries are better served by a central store.
How do I search structured logs precisely?
Parse each line into fields with a tool such as jq, then filter on the field values. The query becomes exact instead of matching text anywhere in the line. Structure is what makes the search reliable.
Can command-line tools handle very large logs?
Yes, several are built for that scale, either by searching fast or by summarizing. The key is choosing the tool that returns the answer you need rather than every matching line. Aggregation often beats reading.
How do I make a search repeatable?
Save the command or pipeline as a script with a clear name. The next time the question comes up, the answer is one command instead of a new hunt. A small library of scripts is the payoff of command-line searching.
Do I still need a central log store?
Usually yes, for long retention and team-wide access. The command line is a complement, not a replacement. Many teams query their central store from the terminal, combining both approaches.
Can I search logs that are not JSON?
Yes, text tools such as ripgrep work on any plain-text log regardless of format. Structured parsing only applies when the lines carry a schema. The two approaches can also be combined in a single pipeline.