Table of Contents
- Log level
- Logger Hierarchy
- Logmanager
In this text I'll try to give your an overview of the java.util.logging
API. Hopefully it is easier to understand, the individual components once your understand the big picture. Many of the concepts described here is also covered in more details in subsequent texts.
Here's an overview diagram of the Java Logging API works:
|
An overview of the core components in the Java Logging API |
All logging are done via a Logger
instance. Loggers gather the data to is logged into a LogRecord
. LogRecord
forwarded to a Handler
. The determines what does with the Handler
LogRecord
. For instance, the LogRecord
can is written to disk, or sent through the network to a surveillance system.
Both Logger
' s and Handler
' s can pass the LogRecord
through a Filter
which determines whether the LogRecord
should be forwarded or not .
A Handler
can also use a to format the as Formatter
LogRecord
a string before it's sent to the external disk or system.
Log level
Whenever a message is logged, the this message was logged with a certain log level. The level is a integer which determines how important the message is. The higher the number (level) is and the more important the message is.
A Logger
can has a minimum log level set on it, which determines if the message was forwarded to a Handler
or not. This isn't a Filter
, even though it has the same effect. For instance, any messages below a certain level can suppressed.
Logger Hierarchy
The Logger
instances is organized into a hierarchy. A Logger
further down in the hierarchy would forward messages logged to it and to its ancestors in the hierarchy. Thus, log levels and messages can be filtered or switched on and off for entire branches of the Logger
hierarchy at a time.
Logmanager
The is a component, that's not displayed in the diagram at the top of this LogManager
text. LogManager
Logger
The holds the hierarchy, and also a global logging configuration, which can is read from a file. The is also covered in more detail in its LogManager
own text.
Java Logging:overview