I am trying to evaluate using slf4j + log4j2 for our application. I read in documents like these about the parameterized messages feature in slf4j: https://www.slf4j.org/faq.html#logging_performance
To understand this feature I tried this code:
int a = 10;
logger.trace("test: " + a++);
logger.error("value of a: " + a);
logger.trace("test {}", a++);
logger.error("value of a " + a);
Logging level is set to ERROR. With that, I was assuming that in the first trace log 'a' will get incremented since it's the old inefficient way of logging. But in the second trace log since I am using parameterized logging and trace level is not enabled, then the 'a++' will also not get evaluated. But looks like it is getting evaluated. I see value as 11 and 12 in the 2 error logs.
Can you please help me understand the slf4j parameterized messages looking at this behavior.
I am using slf4j 1.6.4 and log4j2.7