Logger

The logger is the entry point of the logging framework. This is the instance you use to write messages. The API has, generally, a set of helper methods but the requisite API elements are:

  • To allow passing a level with the message.
  • To allow passing a precomputed message of what is needed to compute a message (it can be a pattern with some variables or a Supplier<> as of Java 8). In this last case, the goal is to not evaluate/interpolate the message if not needed and avoid paying the cost of that computation if the message is hidden.
  • To allow association with an Exception (mainly for error cases) to the message.

The most common example of a logger usage will probably be:

logger.info("Something happent {0}", whatHappent);

This logger ...

Get Java EE 8 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.