Logsflags: g
Log4j Pattern Layout Token
Match Log4j / Logback PatternLayout conversion specifiers like `%d{yyyy-MM-dd}`, `%-5p`, or `%c{1}`.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
%(?:-?\d+)?(?:\.\d+)?[a-zA-Z](?:\{[^}]*\})? (flags: g)Raw source: %(?:-?\d+)?(?:\.\d+)?[a-zA-Z](?:\{[^}]*\})?
How it works
% starts a conversion specifier. (?:-?\d+)? optionally matches a width modifier (negative for left-justify). (?:\.\d+)? optionally matches a max-width. [a-zA-Z] captures the conversion letter (d=date, p=priority, c=category, m=message, n=newline, etc.). (?:\{[^}]*\})? optionally matches a parameter in braces.
Examples
Input
%d{yyyy-MM-dd HH:mm:ss} [%-5p] %c{1} - %m%nMatches
%d{yyyy-MM-dd HH:mm:ss}%-5p%c{1}%m%n
Input
%t %pMatches
%t%p
Input
no log4j tokensNo match
—Common use cases
- •Migrating Log4j config to logback / slf4j
- •Building config UIs for Java logging
- •Documenting custom layouts
- •Detecting deprecated specifiers in CI
Related patterns
CloudWatch Log Stream Path
LogsMatch AWS CloudWatch log group / stream paths like `/aws/lambda/my-function` or `/aws/ecs/cluster-name`.
JSON Log Line (Single-Line Object)
LogsMatch a single-line JSON object — typical of structured logging from services like slog, Bunyan, or Pino.
Apache Common Log Format
LogsParses Apache Common Log Format entries.
Java Stack Trace Line
LogsMatches a single Java stack trace frame line.