When log4j prints a log, a number will be printed in front of it, as shown in the figure.

clipboard.png

log4j.properties is configured as follows

-sharp Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

-sharp A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

-sharp A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%r %d{yyyy-MM-dd HH\:mm\:ss} %c %p -%m%n

two questions

  1. Why is there an extra number in front of it? Sometimes it"s 1, sometimes it"s 2?
  2. Why is the log printed twice?
Sep.25,2021

% r: output the number of milliseconds it took since the application was started to output the log information

Menu