Lesson 34: Java Logging API
Yakov Fain · 2015
This chapter deals with the Java Logging API, which is a part of Java SE. The Java Logging API is implemented in the package java.util.logging. The Java Logging API includes several types of handlers, and the default one is ConsoleHandler that publishes messages on the system console. The Java Logging API supports the following handlers: ConsoleHandler, FileHandler, StreamHandler, SocketHandler and MemoryHandler. Formatters allow one to change the format of logging messages and filters, so the handlers can decide if they are interested in a particular LogRecord. With filters, one can program application logic to decide if a particular LogRecord should be logged. Simple Logging Facade for Java (SLFJ) allows one to decouple the logging API from a particular implementation. SLFJ logging levels include ERROR, WARN, INFO, DEBUG, and TRACE, which correspond to the SEVERE, WARNING, INFO, FINE, FINER levels of the Java Logging API or similar levels in other frameworks.