I assume that Log4j means, that with curly braces they avoid constructing a line when it is not needed (for example, the level is not debugged):
FROM
logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
A string is always evaluated even when it is not registered.
from
logger.debug("Entry number: {} is {}", i, entry[i]);
Log4j can first check the log level and then decide if it is worth building a Message-String.
Log4j uses an inner class ( org.slf4j.helpers.MessageFormatter ) that replaces all {} arguments. You can see the source code in org.slf4j.impl.Log4jLoggerAdapter.debug(String, Object[])
hinneLinks Aug 24 '15 at 14:02 2015-08-24 14:02
source share