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%n

Matches

  • %d{yyyy-MM-dd HH:mm:ss}
  • %-5p
  • %c{1}
  • %m
  • %n

Input

%t %p

Matches

  • %t
  • %p

Input

no log4j tokens

No 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