Skip to content
voidd0Public

About

Parse, filter and aggregate logs. Detects JSON, plain text, nginx, apache, syslog and Python logging formats. Top-N templates, per-bucket stats, stdin and tail -f.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

logparse

Parses log files in several formats and lets you filter by level, time or pattern, count entries, and list the most frequent messages. Reach for it when grep is too blunt for a log you have to read.

npm test license

Install

npm install -g @v0idd0/logparse

Or run it once without installing: npx @v0idd0/logparse --help. Needs Node.js 18 or newer. No dependencies.

Example

The demo file app.log has one JSON object per line. The format is detected from the content. Show only warnings and errors. Output from a real run on 2026-11-26:

$ cat app.log
{"time":"2026-11-26T10:00:01Z","level":"info","msg":"server started"}
{"time":"2026-11-26T10:00:09Z","level":"warn","msg":"slow query 340ms"}
{"time":"2026-11-26T10:00:15Z","level":"error","msg":"connection timeout to db"}
{"time":"2026-11-26T10:00:16Z","level":"error","msg":"connection timeout to db"}
{"time":"2026-11-26T11:20:44Z","level":"info","msg":"request ok"}

$ logparse app.log -l error,warn
  logparse
  ────────────────────────────
  File: app.log
  Filter: level=error,warn

  2026-11-26T10:00:09Z [WARN] slow query 340ms
  2026-11-26T10:00:15Z [ERROR] connection timeout to db
  2026-11-26T10:00:16Z [ERROR] connection timeout to db

  Found: 3 entries

Count the most frequent messages:

$ logparse app.log --top 3
  TOP MESSAGE TEMPLATES
  ─────────────────────
       2  ██████████████████  [ERROR] connection timeout to db
       1  █████████░░░░░░░░░  [INFO] server started
       1  █████████░░░░░░░░░  [WARN] slow query 340ms

Nginx access lines work the same way. Status 500 counts as an error here, 404 as a warning:

$ cat access.log
203.0.113.7 - - [26/Nov/2026:10:01:12 +0000] "GET /index.html HTTP/1.1" 200 5120 "-" "curl/8.5.0"
203.0.113.7 - - [26/Nov/2026:10:01:15 +0000] "GET /missing HTTP/1.1" 404 153 "-" "curl/8.5.0"
198.51.100.4 - - [26/Nov/2026:10:07:40 +0000] "POST /api/login HTTP/1.1" 500 87 "-" "Mozilla/5.0"
198.51.100.4 - - [26/Nov/2026:11:02:03 +0000] "GET /index.html HTTP/1.1" 200 5120 "-" "Mozilla/5.0"

$ logparse access.log --min-level error
  logparse
  ────────────────────────────
  File: access.log
  Filter: min-level=error

  26/Nov/2026:10:07:40 +0000 [ERROR] POST /api/login 500

  Found: 1 entries

Usage

logparse v2.0.5
parse, filter and aggregate logs (JSON, nginx, apache, syslog, plain text)

Usage:
  logparse <file> [options]
  cat app.log | logparse [options]

Input:
  <file>                  Path to log file, or '-' / omit for stdin
  --format <fmt>          Force-parse as one format: text, json, nginx, apache, syslog

Filters:
  -l, --level <levels>    Keep only these levels (comma-sep: debug,info,warn,error,fatal)
  --min-level <level>     Keep entries at or above this severity
  --after <date>          Only entries after date
  --before <date>         Only entries before date
  --last <offset>         Only the last N time (e.g. 1h, 30m, 7d)
  -g, --grep <pattern>    Keep entries matching this regex in message
  -v, --invert <pattern>  Drop entries matching this regex in message

Aggregation:
  -c, --count             Count entries by level, print table
  --top <N>               Top N most-frequent message templates 
  --dedupe                Collapse consecutive repeated messages into "msg (×N)"
  --bucket <offset>       Bucket counts per window (e.g. --bucket 1h)

Output:
  --json                  JSON array
  --ndjson                One JSON object per line
  --csv                   CSV with timestamp,level,message
  -f, --follow            Stream new lines (like tail -f)
  -h, --help              Show this help
  --version               Show version

Examples:
  logparse app.log                            # full parse, colored
  logparse app.log -l error,warn              # errors and warnings
  logparse app.log --min-level warn           # warn + error + fatal
  logparse app.log --last 1h -g "timeout"     # last hour + match
  logparse app.log --top 10                   # 10 noisiest templates
  logparse app.log --bucket 1h --json         # requests per hour
  logparse access.log --format nginx --json   # parse nginx combined
  tail -f app.log | logparse --min-level error # live error-only stream
  journalctl -u myapp | logparse --format syslog --top 5

Docs and issues: https://github.com/voidd0/logparse

Formats

logparse detects JSON lines, nginx and apache access logs, syslog, Python logging and plain text, or you can force one with --format. Lines it cannot parse are kept as plain text entries. It reads a file, stdin, or a growing file with --follow.

License

MIT, see LICENSE.


Made by vøiddo. More command line tools: voiddo.com/packages. We also run data scrapers for job boards, shops and ad libraries: voiddo.com/scrapers.

About

Parse, filter and aggregate logs. Detects JSON, plain text, nginx, apache, syslog and Python logging formats. Top-N templates, per-bucket stats, stdin and tail -f.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages