A fast, colorized terminal log file analyzer. Parse, filter, and summarize log files with zero dependencies beyond Python 3.8+.
- Colorized output — errors in red, warnings in yellow, info in green, debug in gray
- Pattern matching — grep with regex and context lines
- Severity detection — auto-detects log levels (ERROR, WARN, INFO, DEBUG, etc.)
- Statistics summary — line counts, severity breakdown, time range analysis
- Tail mode — follow log files in real-time (like
tail -fbut smarter) - Multiple formats — auto-detects common log formats (syslog, JSON, Apache, Nginx)
- Zero dependencies — pure Python, no pip install needed
git clone https://github.com/sickagents/loglens.git
cd loglens
chmod +x loglens.py
# Optional: add to PATH
ln -s $(pwd)/loglens.py /usr/local/bin/loglens# Analyze a log file with colorized output
python3 loglens.py /var/log/syslog
# Show only errors and warnings
python3 loglens.py app.log --level ERROR,WARN
# Get statistics summary
python3 loglens.py app.log --stats# Search for a pattern with context
python3 loglens.py app.log --grep "timeout" --context 2
# Use regex patterns
python3 loglens.py app.log --grep "5\d{2}.*timeout"# Tail with colorized output and severity filtering
python3 loglens.py /var/log/syslog --follow
# Follow and auto-highlight errors
python3 loglens.py app.log -f --level ERROR# Parse JSON-structured logs (auto-detected)
python3 loglens.py app.json.log
# Specify JSON field mapping
python3 loglens.py app.json.log --json-fields timestamp,message,level# Export filtered results as JSON
python3 loglens.py app.log --level ERROR --export json
# Export as CSV
python3 loglens.py app.log --stats --export csv| Flag | Description |
|---|---|
--level, -l |
Filter by severity: ERROR,WARN,INFO,DEBUG,TRACE |
--grep, -g |
Regex pattern to search for |
--context, -c |
Lines of context around matches (default: 0) |
--follow, -f |
Real-time tail mode |
--stats, -s |
Show statistics summary |
--export |
Export format: json, csv |
--json-fields |
Comma-separated JSON field names for timestamp,message,level |
--no-color |
Disable colorized output |
--tail, -t |
Show last N lines |
--since |
Show entries after this time (ISO 8601 or relative like 1h, 30m) |
loglens automatically detects:
- Syslog —
Jun 15 10:00:00 hostname service[pid]: message - Apache/Nginx —
127.0.0.1 - - [15/Jun/2026:10:00:00 +0000] "GET / HTTP/1.1" 200 - JSON —
{"timestamp":"...","level":"error","message":"..."} - Python —
2026-06-15 10:00:00,000 - module - ERROR - message - Java/Spring —
2026-06-15 10:00:00.000 ERROR [thread] class - message - Generic — Falls back to severity keyword detection
MIT