Name

Package java.util.logging

Synopsis

The java.util.logging package defines a sophisticated and highly-configurable logging facility that Java applications can use to emit, filter, format, and output warning, diagnostic, tracing and debugging messages. An application generates log messages by calling various methods of a Logger object. The content of a log message (with other pertinant details such as the time and sequence number) is encapsulated in a LogRecord object generated by the Logger. A Handler object represents a destination for LogRecord objects. Concrete subclasses of Handler support destinations such as files and sockets. Most Handler objects have an associated Formatter that converts a LogRecord object into the actual text that is logged. The subclasses SimpleFormatter and XMLFormatter produce simple plain-text log messages and detailed XML logs respectively.

Each log message has an associated severity level. The Level class defines a type-safe enumeration of defined levels. Logger and Handler objects both have an associated Level, and discard any log messages whose severity is less than that specified level. In addition to this level-based filtering, Logger and Handler objects may also have an associated Filter object which may be implemented to filter log messages based on any desired criteria.

Applications that desire complete control over the logs they generate can create a Logger object, along with Handler, Formatter and Filter objects that control the destination, ...

Get Java in a Nutshell, 5th Edition 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.