APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.util.logging

public Class LogManager

extends Object
Class Inheritance
Imports
java.io.*, java.util.*, java.lang.ref.ReferenceQueue, .WeakReference, java.util.concurrent.ConcurrentHashMap, .CopyOnWriteArrayList, java.nio.file.Paths, java.util.concurrent.locks.ReentrantLock, java.util.function.BiFunction, .Function, .Predicate, java.util.stream.Collectors, .Stream, sun.util.logging.internal.LoggingProviderImpl

There is a single global LogManager object that is used to maintain a set of shared state about Loggers and log services.

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.

LogManager Configuration

A LogManager initializes the logging configuration via the 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:

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:

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.

Since
1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
pack-priv static enum
pack-priv class
pack-priv class
private static class
LogManager.LoggingProviderAccess

This class allows the LoggingProviderImpl to demand loggers on behalf of system and application classes.

private static class
pack-priv static enum
LogManager.ModType

Type of the modification for a given property.

private class
pack-priv class
pack-priv static class
LogManager.VisitedLoggers

An object that keep track of loggers we have already visited.

Field Summary

Modifier and TypeField and Description
private final CopyOnWriteArrayList<LogManager.CloseOnReset>
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<Object, Runnable>
private final ReferenceQueue<Logger>
public static final String
LOGGING_MXBEAN_NAME

String representation of the java.management/javax.management.ObjectName for the management interface for the logging facility.

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.LoggerContext
private final LogManager.LoggerContext

Constructor Summary

AccessConstructor and Description
protected
LogManager()

Protected constructor.

Method Summary

Modifier and TypeMethod and Description
public LogManager

Returns:

This LogManager.
addConfigurationListener
(Runnable
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

Returns:

true if the argument logger was registered successfully, false if a logger of that name already exists.
addLogger
(Logger
the new logger.
logger
)

Add a named logger.

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<LogManager.LoggerContext>
private List<Handler>
createLoggerHandlers(final String name, final String handlersPropertyName)

pack-priv Logger
demandLogger(String name, String resourceBundleName, Class<?> caller)

pack-priv Logger
demandLogger(String name, String resourceBundleName, Module module)

pack-priv Logger
demandSystemLogger(String name, String resourceBundleName, Class<?> caller)

pack-priv Logger
demandSystemLogger(String name, String resourceBundleName, Module module)

pack-priv final void
pack-priv final void
private boolean
pack-priv boolean
getBooleanProperty(String name, boolean defaultValue)

pack-priv String
pack-priv Filter
getFilterProperty(String name, Filter defaultValue)

pack-priv Formatter
pack-priv int
getIntProperty(String name, int defaultValue)

pack-priv Level
getLevelProperty(String name, Level defaultValue)

public Logger

Returns:

matching logger or null if none is found
getLogger
(String
name of the logger
name
)

Method to find a named logger.

public Enumeration<String>

Returns:

enumeration of logger name strings
getLoggerNames
()

Get an enumeration of known logger names.

public static synchronized LoggingMXBean

Returns:

a LoggingMXBean object.
getLoggingMXBean
()
Deprecated since 9. java.util.logging.LoggingMXBean is deprecated and replaced with java.lang.management.PlatformLoggingMXBean.

Returns LoggingMXBean for managing loggers.

public static LogManager

Returns:

the global LogManager object
getLogManager
()

Returns the global LogManager object.

pack-priv long
getLongProperty(String name, long defaultValue)

public String

Returns:

property value
getProperty
(String
property name
name
)

Get the value of a logging property.

pack-priv String
getStringProperty(String name, String defaultValue)

pack-priv final LogManager.LoggerContext
private LogManager.LoggerContext
private void
private static LogManager
private void
private void
loadLoggerHandlers(final Logger logger, final String name, final String handlersPropertyName)

private String[]
parseClassNames(String propertyName)

public void
readConfiguration()

Reads and initializes the logging configuration.

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
reset()

Reset the logging configuration.

private void
private void
private void
private void
setLoggerHandlers(final Logger logger, final String name, final String handlersPropertyName, List<Handler> handlers)

private static String
trim(String value)

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 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.
mapper
)

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 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.
mapper
)

Updates the logging configuration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait