Stay organized with collections
Save and categorize content based on your preferences.
java.util.logging
Provides the classes and interfaces of
the Java 2 platform's core logging facilities.
The central goal of the logging APIs is to support maintaining and servicing
software at customer sites.
There are four main target uses of the logs:
- Problem diagnosis by end users and system administrators.
This consists of simple logging of common problems that can be fixed
or tracked locally, such as running out of resources, security failures,
and simple configuration errors.
- Problem diagnosis by field service engineers. The logging information
used by field service engineers may be considerably more complex and
verbose than that required by system administrators. Typically such information
will require extra logging within particular subsystems.
- Problem diagnosis by the development organization.
When a problem occurs in the field, it may be necessary to return the captured logging
information to the original development team for diagnosis. This logging
information may be extremely detailed and fairly inscrutable. Such information might include
detailed tracing on the internal execution of particular subsystems.
- Problem diagnosis by developers. The Logging APIs may also be
used to help debug an application under development. This may
include logging information generated by the target application
as well as logging information generated by lower-level libraries.
Note however that while this use is perfectly reasonable,
the logging APIs are not intended to replace the normal debugging
and profiling tools that may already exist in the development environment.
The key elements of this package include:
- Logger: The main entity on which applications make
logging calls. A Logger object is used to log messages
for a specific system or application
component.
- LogRecord: Used to pass logging requests between the logging
framework and individual log handlers.
- Handler: Exports LogRecord objects to a variety of destinations
including memory, output streams, consoles, files, and sockets.
A variety of Handler subclasses exist for this purpose. Additional Handlers
may be developed by third parties and delivered on top of the core platform.
- Level: Defines a set of standard logging levels that can be used
to control logging output. Programs can be configured to output logging
for some levels while ignoring output for others.
- Filter: Provides fine-grained control over what gets logged,
beyond the control provided by log levels. The logging APIs support a general-purpose
filter mechanism that allows application code to attach arbitrary filters to
control logging output.
- Formatter: Provides support for formatting LogRecord objects. This
package includes two formatters, SimpleFormatter and
XMLFormatter, for formatting log records in plain text
or XML respectively. As with Handlers, additional Formatters
may be developed by third parties.
The Logging APIs offer both static and dynamic configuration control.
Static control enables field service staff to set up a particular configuration and then re-launch the
application with the new logging settings. Dynamic control allows for updates to the
logging configuration within a currently running program. The APIs also allow for logging to be
enabled or disabled for different functional areas of the system. For example,
a field service engineer might be interested in tracing all AWT events, but might have no interest in
socket events or memory management.
Null Pointers
In general, unless otherwise noted in the javadoc, methods and
constructors will throw NullPointerException if passed a null argument.
The one broad exception to this rule is that the logging convenience
methods in the Logger class (the config, entering, exiting, fine, finer, finest,
log, logp, logrb, severe, throwing, and warning methods)
will accept null values
for all arguments except for the initial Level argument (if any).
For an overview of control flow,
please refer to the
Java Logging Overview
Interfaces
Filter |
A Filter can be used to provide fine grain control over
what is logged, beyond the control provided by log levels.
|
LoggingMXBean |
The management interface for the logging facility.
|
Classes
ConsoleHandler |
This Handler publishes log records to System.err.
|
ErrorManager |
ErrorManager objects can be attached to Handlers to process
any error that occurs on a Handler during Logging.
|
FileHandler |
Simple file logging Handler.
|
Formatter |
A Formatter provides support for formatting LogRecords.
|
Handler |
A Handler object takes log messages from a Logger and
exports them.
|
Level |
The Level class defines a set of standard logging levels that
can be used to control logging output.
|
Logger |
A Logger object is used to log messages for a specific
system or application component.
|
LoggingPermission |
Legacy security code; do not use.
|
LogManager |
There is a single global LogManager object that is used to
maintain a set of shared state about Loggers and log services.
|
LogRecord |
LogRecord objects are used to pass logging requests between
the logging framework and individual log Handlers.
|
MemoryHandler |
Handler that buffers requests in a circular buffer in memory.
|
SimpleFormatter |
Print a brief summary of the LogRecord in a human readable
format.
|
SocketHandler |
Simple network logging Handler.
|
StreamHandler |
Stream based logging Handler.
|
XMLFormatter |
Format a LogRecord into a standard XML format.
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# java.util.logging\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\njava.util.logging\n=================\n\nProvides the classes and interfaces of the Java 2 platform's core logging facilities. The central goal of the logging APIs is to support maintaining and servicing software at customer sites.\n\n\nThere are four main target uses of the logs:\n\n1. *Problem diagnosis by end users and system administrators*. This consists of simple logging of common problems that can be fixed or tracked locally, such as running out of resources, security failures, and simple configuration errors.\n2. *Problem diagnosis by field service engineers*. The logging information used by field service engineers may be considerably more complex and verbose than that required by system administrators. Typically such information will require extra logging within particular subsystems.\n3. *Problem diagnosis by the development organization*. When a problem occurs in the field, it may be necessary to return the captured logging information to the original development team for diagnosis. This logging information may be extremely detailed and fairly inscrutable. Such information might include detailed tracing on the internal execution of particular subsystems.\n4. *Problem diagnosis by developers*. The Logging APIs may also be used to help debug an application under development. This may include logging information generated by the target application as well as logging information generated by lower-level libraries. Note however that while this use is perfectly reasonable, the logging APIs are not intended to replace the normal debugging and profiling tools that may already exist in the development environment.\n\n\nThe key elements of this package include:\n\n- *Logger*: The main entity on which applications make logging calls. A Logger object is used to log messages for a specific system or application component.\n- *LogRecord*: Used to pass logging requests between the logging framework and individual log handlers.\n- *Handler*: Exports LogRecord objects to a variety of destinations including memory, output streams, consoles, files, and sockets. A variety of Handler subclasses exist for this purpose. Additional Handlers may be developed by third parties and delivered on top of the core platform.\n- *Level*: Defines a set of standard logging levels that can be used to control logging output. Programs can be configured to output logging for some levels while ignoring output for others.\n- *Filter*: Provides fine-grained control over what gets logged, beyond the control provided by log levels. The logging APIs support a general-purpose filter mechanism that allows application code to attach arbitrary filters to control logging output.\n- *Formatter*: Provides support for formatting LogRecord objects. This package includes two formatters, SimpleFormatter and XMLFormatter, for formatting log records in plain text or XML respectively. As with Handlers, additional Formatters may be developed by third parties.\n\n\nThe Logging APIs offer both static and dynamic configuration control.\nStatic control enables field service staff to set up a particular configuration and then re-launch the\napplication with the new logging settings. Dynamic control allows for updates to the\nlogging configuration within a currently running program. The APIs also allow for logging to be\nenabled or disabled for different functional areas of the system. For example,\na field service engineer might be interested in tracing all AWT events, but might have no interest in\nsocket events or memory management.\n\nNull Pointers\n-------------\n\n\nIn general, unless otherwise noted in the javadoc, methods and\nconstructors will throw NullPointerException if passed a null argument.\nThe one broad exception to this rule is that the logging convenience\nmethods in the Logger class (the config, entering, exiting, fine, finer, finest,\nlog, logp, logrb, severe, throwing, and warning methods)\nwill accept null values\nfor all arguments except for the initial Level argument (if any).\n\nRelated Documentation\n---------------------\n\n\nFor an overview of control flow,\nplease refer to the\n[Java Logging Overview](https://docs.oracle.com/pls/topic/lookup?ctx=javase17&id=logging_overview)\n\nInterfaces\n----------\n\n|-------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|\n| [Filter](/reference/java/util/logging/Filter) | A Filter can be used to provide fine grain control over what is logged, beyond the control provided by log levels. |\n| [LoggingMXBean](/reference/java/util/logging/LoggingMXBean) | The management interface for the logging facility. |\n\nClasses\n-------\n\n|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| [ConsoleHandler](/reference/java/util/logging/ConsoleHandler) | This Handler publishes log records to System.err. |\n| [ErrorManager](/reference/java/util/logging/ErrorManager) | ErrorManager objects can be attached to Handlers to process any error that occurs on a Handler during Logging. |\n| [FileHandler](/reference/java/util/logging/FileHandler) | Simple file logging Handler. |\n| [Formatter](/reference/java/util/logging/Formatter) | A Formatter provides support for formatting LogRecords. |\n| [Handler](/reference/java/util/logging/Handler) | A Handler object takes log messages from a Logger and exports them. |\n| [Level](/reference/java/util/logging/Level) | The Level class defines a set of standard logging levels that can be used to control logging output. |\n| [Logger](/reference/java/util/logging/Logger) | A Logger object is used to log messages for a specific system or application component. |\n| [LoggingPermission](/reference/java/util/logging/LoggingPermission) | Legacy security code; do not use. |\n| [LogManager](/reference/java/util/logging/LogManager) | There is a single global LogManager object that is used to maintain a set of shared state about Loggers and log services. |\n| [LogRecord](/reference/java/util/logging/LogRecord) | LogRecord objects are used to pass logging requests between the logging framework and individual log Handlers. |\n| [MemoryHandler](/reference/java/util/logging/MemoryHandler) | Handler that buffers requests in a circular buffer in memory. |\n| [SimpleFormatter](/reference/java/util/logging/SimpleFormatter) | Print a brief summary of the `LogRecord` in a human readable format. |\n| [SocketHandler](/reference/java/util/logging/SocketHandler) | Simple network logging Handler. |\n| [StreamHandler](/reference/java/util/logging/StreamHandler) | Stream based logging Handler. |\n| [XMLFormatter](/reference/java/util/logging/XMLFormatter) | Format a LogRecord into a standard XML format. |\n\n-\n\n Interfaces\n ----------\n\n - [Filter](/reference/java/util/logging/Filter)\n - [LoggingMXBean](/reference/java/util/logging/LoggingMXBean)\n-\n\n Classes\n -------\n\n - [ConsoleHandler](/reference/java/util/logging/ConsoleHandler)\n - [ErrorManager](/reference/java/util/logging/ErrorManager)\n - [FileHandler](/reference/java/util/logging/FileHandler)\n - [Formatter](/reference/java/util/logging/Formatter)\n - [Handler](/reference/java/util/logging/Handler)\n - [Level](/reference/java/util/logging/Level)\n - [Logger](/reference/java/util/logging/Logger)\n - [LoggingPermission](/reference/java/util/logging/LoggingPermission)\n - [LogManager](/reference/java/util/logging/LogManager)\n - [LogRecord](/reference/java/util/logging/LogRecord)\n - [MemoryHandler](/reference/java/util/logging/MemoryHandler)\n - [SimpleFormatter](/reference/java/util/logging/SimpleFormatter)\n - [SocketHandler](/reference/java/util/logging/SocketHandler)\n - [StreamHandler](/reference/java/util/logging/StreamHandler)\n - [XMLFormatter](/reference/java/util/logging/XMLFormatter)"]]