you can use the printf syntax in Log4j2 already.
When obtaining a logger, do this:

Logger log = LogManager.getLogger(MyClass.class, new StringFormatterMessageFactory());
log.debug("Here's a message with an int %d, a double %f and a String %s, myInt, myDouble, myString);

as of beta-8 you can even do:
Logger log = LogManager.getLogger(new StringFormatterMessageFactory()); // no need for MyClass.class

Best regards,


From: Jürgen Weber <juergen@jwi.de>
To: log4j-dev@logging.apache.org
Sent: Friday, July 5, 2013 10:54 PM
Subject: logger.printf()


I do like printf. What do you think of adding

logger.printf(LEVEL, ...)

so one could easily replace System.out.printf(..) with
logger.printf(Level.DEBUG, ...)


To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org