Log4j Formatting Pattern for Eclipse

When debugging in Eclipse, dense Log4j output can bury the signal. The pattern below right-aligns logger names and keeps each entry compact within the console view.

Add the line to your log4j.properties file:

log4j.appender.stdout.layout.ConversionPattern=%-5p %40.40c{2} - %m%n
  • %-5p left-aligns the log level in a five-character column.
  • %40.40c{2} pads the logger name to forty characters and abbreviates the package to two levels.
  • %m%n prints the original message followed by a newline.

Usage Tips

  • Combine with log4j.appender.stdout.Target=System.out to keep Eclipse from colouring error messages red.
  • For Log4j 2.x, use the equivalent pattern: %level %-40.40logger{2} - %msg%n.
  • Avoid logging sensitive data when copying console output to issue trackers; scrub credentials before sharing.