[slf4j-user] When more parameters than placeholders, extra parameters are not logged
jo at durchholz.org
jo at durchholz.org
Sun Feb 2 10:35:59 UTC 2025
An additional thought:
Modern JVMs are pretty efficient at building closures.
Log4j2 (not the old log4j version 1) is an alternative where you can replace
logger.debug("foo is: " + foo)
with
logger.debug(() -> "foo is: " + foo)
This has the same avoid-constructing-strings logic as
logger.debug("foo is: {}", foo)
but you don't need to refactor anything.
The downside is that forgetting to create the closure will make logging
slow, so in the end, you'll likely fall back to the same
make-sure-everything-is-mass-refactored approach as before, so the
overall advantage isn't big.
However, you'll get low-hanging fruits faster, at the expense of having
to try out a different logging framework.
Which means I won't recommend anything, I'm just presenting more choices
in the hopes that one of them matches your situation better.
Regards,
Jo
More information about the slf4j-user
mailing list