Advertisement

Pattern library / Dev & Logs

Log Level Regex (DEBUG / INFO / WARN / ERROR / FATAL)

Every log format differs, but the level token is nearly always one of five words in brackets, dashes or pipes: 2026-10-28 14:30:01 ERROR something failed. One pattern with an alternation handles the common layouts — use it in grep, log shippers, or as the filter behind a dashboard widget.

The pattern
\b(DEBUG|INFO|WARN|WARNING|ERROR|ERR|FATAL|CRITICAL)\b
Load this pattern into the tester →

How the pattern works

Test it: match & no-match examples

Every row is loaded straight into the tester — click Try to see the match live:

InputResultWhy
2026-10-28 14:30:01 ERROR db timeout after 30sMatchseverity foundTry →
[WARN] cache miss ratio 82%Matchbracketed levelTry →
level=info msg="server started"No matchlowercase level — needs i flag (see pitfalls)Try →
DEBUG verbose worker tickMatchplain prefixTry →
an error occurred (handled)No matchlowercase prose — see pitfallsTry →
2026-10-28 INFO_OK doneNo match_glued — no word boundaryTry →

Where to use it

Bash (errors only)

grep -E '\b(DEBUG|INFO|WARN|ERROR|FATAL)\b' app.log | grep -Ev '\b(DEBUG|INFO)\b'  # warn+ only

JavaScript (log viewer filter)

const LEVEL = /\b(DEBUG|INFO|WARN|WARNING|ERROR|ERR|FATAL|CRITICAL)\b/;
lines.filter(l => /\b(ERROR|FATAL|CRITICAL)\b/.test(l));

BigQuery (structured logs)

SELECT REGEXP_EXTRACT(message, r'\b(DEBUG|INFO|WARN|ERROR|FATAL)\b') AS level,
       COUNT(*) FROM logs GROUP BY 1

Common mistakes

Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
Open the regex tester →

FAQ

How do I match only ERROR-level lines?

Tighten the alternation: \b(ERROR|FATAL|CRITICAL)\b — or anchor the whole line: ^.*\bERROR\b.*$ for grep -E.

Why doesn't ERROR_RATE match?

Word boundaries — _ is a word character, so ERROR in ERROR_RATE has no boundary after it. That protects you from false hits; drop \b if you really want substring matches.

How do I capture the timestamp and level together?

^([0-9-]+ [0-9:,]+) (DEBUG|INFO|WARN|ERROR|FATAL) — group 1 is the time, group 2 the level. Adjust the time part to your log format.

ISO 8601 DateTime Regex — Match & Test Online · Quoted String Regex — Match "..." and '...' · IPv4 Address Regex — Validate Dots & Octets

For GA4-specific patterns, see the GA4 regex cheat sheet, the page path regex guide, the event filter regex guide, the GA4 regex match types, the custom channel grouping guide and RE2 vs PCRE. Browse the full regex pattern library.