Skip to content

LOG4J2_MANUALLY_PROVIDED_MESSAGE

Summary

  • Rule ID: LOG4J2_MANUALLY_PROVIDED_MESSAGE
  • Name: Log4j2 preformatted message
  • Problem: Preformatting messages before logging bypasses placeholder-based logging benefits.

What This Rule Reports

This rule reports Log4j2 logger calls where message text is manually formatted before the logging API call.

Java Example (reported)

LOG.info(String.format("user=%s action=%s", varOne, varTwo));

What This Rule Does Not Report

  • Placeholder-based logging calls
  • Message-only forms that are not manually preformatted

Java Example (not reported)

LOG.info("user={} action={}", varOne, varTwo);

Use Log4j2 placeholders and pass dynamic values as separate arguments.

Message Shape

Findings explain that Log4j2 messages should use placeholders instead of manual formatting.