logger.debug(“Logging in user {} with birthday {}”, user.getName(), user.getBirthdayCalendar());
使用String.format的形式格式化参数
log4j2 中除了支持{}
的参数占位符,还支持String.format
的形式:
public static Logger logger = LogManager.getFormatterLogger(“Foo”);
logger.debug(“Logging in user %s with birthday %s”, user.getName(), user.getBirthdayCalendar());
logger.debug(“Logging in user %1 s w i t h b i r t h d a y s with birthday %2 s with birthda