This LogManager object:
The global LogManager object can be retrieved using LogManager.getLogManager(). The LogManager object is created during class initialization and cannot subsequently be changed.
At startup the LogManager class is located using the java.util.logging.manager system property.
readConfiguration() method during LogManager initialization.
By default, LogManager default configuration is used.
The logging configuration read by LogManager must be in the
properties file format.
The LogManager defines two optional system properties that allow control over
the initial configuration, as specified in the readConfiguration()
method:
java.util.logging.config.class
java.util.logging.config.file
These two system properties may be specified on the command line to the "java" command, or as system property definitions passed to JNI_CreateJavaVM.
The properties for loggers and Handlers will have
names starting with the dot-separated name for the handler or logger.
The global logging properties may include:
true. When the
value is true, the handlers associated with the logger are guaranteed
to be closed on reset and shutdown. This can be turned off
by explicitly setting "<logger>.handlers.ensureCloseOnReset=false" in
the configuration. Note that turning this property off causes the risk of
introducing a resource leak, as the logger may get garbage collected before
reset() is called, thus preventing its handlers from being closed
on reset(). In that case it is the responsibility of the application
to ensure that the handlers are closed before the logger is garbage
collected.
Note that all classes loaded during LogManager configuration are first searched on the system class path before any user class path. That includes the LogManager class, any config classes, and any handler classes.
Loggers are organized into a naming hierarchy based on their dot separated names. Thus "a.b.c" is a child of "a.b", but "a.b1" and a.b2" are peers.
All properties whose names end with ".level" are assumed to define log levels for Loggers. Thus "foo.level" defines a log level for the logger called "foo" and (recursively) for any of its children in the naming hierarchy. Log Levels are applied in the order they are defined in the properties file. Thus level settings for child nodes in the tree should come after settings for their parents. The property name ".level" can be used to set the level for the root of the tree.
All methods on the LogManager object are multi-thread safe.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private static class | |
| pack-priv static enum | |
| pack-priv class | |
| pack-priv class | |
| private static class | LogManager.
This class allows the |
| private static class | |
| pack-priv static enum | LogManager.
Type of the modification for a given property. |
| private class | |
| pack-priv class | |
| pack-priv static class | LogManager.
An object that keep track of loggers we have already visited. |
| Modifier and Type | Field and Description |
|---|---|
| private final CopyOnWriteArrayList | |
| private final ReentrantLock | |
| private static final Level | |
| private volatile int | |
| private volatile boolean | |
| private boolean | initializedCalled
Lazy initialization: if this instance of manager is the global manager then this method will read the initial configuration and add the root logger and global logger by calling addLogger(). |
| private final Map | |
| private final ReferenceQueue | |
| public static final String | LOGGING_MXBEAN_NAME
String representation of the
|
| private static final LogManager | |
| private static final int | |
| private volatile Properties | |
| private volatile boolean | |
| private volatile Logger | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private final LogManager. | |
| private final LogManager. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public LogManager | Returns: This LogManager.A configuration listener that will be invoked after the
configuration changed. listener)Adds a configuration listener to be invoked each time the logging configuration is read. |
| public boolean | |
| public void | checkAccess()
Deprecated
for removal since 17. This method originally checked that the current context was
trusted to modify the logging configuration.
Does nothing. |
| private void | |
| private List | |
| private List | |
| pack-priv Logger | |
| pack-priv Logger | |
| pack-priv Logger | |
| pack-priv Logger | |
| pack-priv final void | |
| pack-priv final void | |
| private boolean | |
| pack-priv boolean | |
| pack-priv String | |
| pack-priv Filter | |
| pack-priv Formatter | |
| pack-priv int | |
| pack-priv Level | |
| public Logger | |
| public Enumeration | Returns: enumeration of logger name stringsGet an enumeration of known logger names. |
| public static synchronized LoggingMXBean | Returns: aLoggingMXBean object.
Deprecated
since 9.
java.util.logging.LoggingMXBean is deprecated and
replaced with java.lang.management.PlatformLoggingMXBean.
Returns |
| public static LogManager | |
| pack-priv long | |
| public String | |
| pack-priv String | |
| pack-priv final LogManager. | |
| private LogManager. | |
| private void | |
| private static LogManager | |
| private void | |
| private void | |
| private String[] | |
| public void | |
| public void | readConfiguration(InputStream
stream to read properties from ins)Reads and initializes the logging configuration from the given input stream. |
| private void | |
| public void | removeConfigurationListener(Runnable
the configuration listener to remove. listener)Removes a previously registered configuration listener. |
| public void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private static String | |
| public void | updateConfiguration(Function<String, BiFunction<String, String, String>>
a functional interface that takes a configuration
key k and returns a function f(o,n) whose returned
value will be applied to the resulting configuration. The
function f may return mapper)null to indicate that the property
k will not be added to the resulting configuration.
If mapper is null then (k) -> ((o, n) -> n) is
assumed.
For each k, the mapped function f will be invoked with the value associated with k in the old configuration (i.e o) and the value associated with k in the new configuration (i.e. n). A null value for o or n indicates that no
value was present for k in the corresponding configuration.Updates the logging configuration. |
| public void | updateConfiguration(InputStream
a stream to read properties from ins, Function<String, BiFunction<String, String, String>> a functional interface that takes a configuration
key k and returns a function f(o,n) whose returned
value will be applied to the resulting configuration. The
function f may return mapper)null to indicate that the property
k will not be added to the resulting configuration.
If mapper is null then (k) -> ((o, n) -> n) is
assumed.
For each k, the mapped function f will be invoked with the value associated with k in the old configuration (i.e o) and the value associated with k in the new configuration (i.e. n). A null value for o or n indicates that no
value was present for k in the corresponding configuration.Updates the logging configuration. |