Logsflags: g
Logfmt Key-Value Pair
Parse key=value pairs from logfmt-style log lines, supporting both quoted and unquoted values.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
([a-zA-Z_][\w.]*)=("[^"]*"|\S+) (flags: g)Raw source: ([a-zA-Z_][\w.]*)=("[^"]*"|\S+)
How it works
([a-zA-Z_][\w.]*) captures the key: starts with a letter or underscore, followed by word chars or dots. = is a literal separator. ("[^"]*"|\S+) captures the value: either a double-quoted string (allowing spaces inside) or an unquoted sequence of non-whitespace characters.
Examples
Input
level=info msg="user logged in" user_id=42Matches
level=infomsg="user logged in"user_id=42
Input
ts=2024-01-15T14:30:00Z status=200 latency=12msMatches
ts=2024-01-15T14:30:00Zstatus=200latency=12ms
Common use cases
- •Parsing logfmt output from Go services (standard library log/slog)
- •Extracting structured fields from Heroku and Fly.io log drains
- •Log aggregation pipelines (Vector, Fluentd, Filebeat)
- •Building log dashboards from structured text logs