Logger Factory

The Logger Factory is generally a utility method (static) giving you a logger instance.

Most of the time, it looks like this:

final Logger logger = LoggerFactory.getLogger(...);// orfinal Logger logger = Logger.getLogger(...);

The Logger Factory is either a specific class or the Logger class itself depending on the logging framework, but in all cases, it gives you a Logger instance. The parameter of this factory method can change, but generally leads to a String (a lot of libraries allow a Class shortcut) which can be used to configure the log level as we saw earlier in the JUL configuration file.

Why do logger frameworks need a factory and why don't they allow you to instantiate the logger yourself with a plain new? Because ...

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.