Logsflags: g

Log Level

Matches standard log level keywords in log lines.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("\\b(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\\b", "g");
const input = "[INFO] Server started. [ERROR] Connection failed.";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
\b(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\b   (flags: g)

Raw source: \b(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\b

How it works

`\b(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\b` matches any of the six standard log levels as whole words.

Examples

Input

[INFO] Server started. [ERROR] Connection failed.

Matches

  • INFO
  • ERROR

Input

DEBUG: cache miss

Matches

  • DEBUG

Common use cases

  • Log filtering
  • Alerting
  • Error triage

Related patterns

Related concepts