Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

SLF4J delegates the actual logging to a concrete framework like Log4J, java.commons.logging, etc by adding the related binding jar to the classpath . In this project we use the Log4J successor LogBack.

Formatting

Including variables in the log statement

If the string defined in the log message is dynamic, eg. includes variables or calculations, they should only be generated if the logging is actually going to be performed for the given log statement. This can be achieved by parameterizing the log message with the {} placeholder, eg.

Code Block

log.debug(" Received message was {}", message):

See What is the fastest way of (not) logging? for details

Child pages (Children Display)
excerpttrue
excerptTypesimple