# LogManager

public class **LogManager** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
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:

- Manages a hierarchical namespace of Logger objects. All named Loggers are stored in this namespace.
- Manages a set of logging control properties. These are simple key-value pairs that can be used by Handlers and other logging objects to configure themselves.


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.


The LogManager defines two optional system properties that allow control over
the initial configuration:

- "java.util.logging.config.class"
- "java.util.logging.config.file"

These two properties may be specified on the command line to the "java" command, or as system property definitions passed to JNI_CreateJavaVM.


If the "java.util.logging.config.class" property is set, then the
property value is treated as a class name. The given class will be
loaded, an object will be instantiated, and that object's constructor
is responsible for reading in the initial configuration. (That object
may use other system properties to control its configuration.) The
alternate configuration class can use readConfiguration(InputStream)
to define properties in the LogManager.


If "java.util.logging.config.class" property is **not** set,
then the "java.util.logging.config.file" system property can be used
to specify a properties file (in java.util.Properties format). The
initial logging configuration will be read from this file.


If neither of these properties is defined then the LogManager uses its
default configuration. The default configuration is typically loaded from the
properties file "`lib/logging.properties`" in the Java installation
directory.


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:

- A property "handlers". This defines a whitespace or comma separated list of class names for handler classes to load and register as handlers on the root Logger (the Logger named ""). Each class name must be for a Handler class which has a default constructor. Note that these Handlers may be created lazily, when they are first used.
- A property "\<logger\>.handlers". This defines a whitespace or comma separated list of class names for handlers classes to load and register as handlers to the specified logger. Each class name must be for a Handler class which has a default constructor. Note that these Handlers may be created lazily, when they are first used.
- A property "\<logger\>.useParentHandlers". This defines a boolean value. By default every logger calls its parent in addition to handling the logging message itself, this often result in messages being handled by the root logger as well. When setting this property to false a Handler needs to be configured for this logger otherwise no logging messages are delivered.
- A property "config". This property is intended to allow arbitrary configuration code to be run. The property defines a whitespace or comma separated list of class names. A new instance will be created for each named class. The default constructor of each class may execute arbitrary code to update the logging configuration, such as setting logger levels, adding handlers, adding filters, etc.


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.

### Constant Summary

|---|---|---|
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [LOGGING_MXBEAN_NAME](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#LOGGING_MXBEAN_NAME) | String representation of the `ObjectName` for the management interface for the logging facility. |

### Protected Constructor Summary

|---|---|
|   | [LogManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#LogManager())() Protected constructor. |

### Public Method Summary

|---|---|
| boolean | [addLogger](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#addLogger(java.util.logging.Logger))([Logger](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Logger.html) logger) Add a named logger. |
| void | [addPropertyChangeListener](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#addPropertyChangeListener(java.beans.PropertyChangeListener))([PropertyChangeListener](https://developers.google.com/j2objc/javadoc/jre/reference/java/beans/PropertyChangeListener.html) l) *This method is deprecated. The dependency on `PropertyChangeListener` creates a significant impediment to future modularization of the Java platform. This method will be removed in a future release. The global `LogManager` can detect changes to the logging configuration by overridding the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#readConfiguration()` method.* |
| void | [checkAccess](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#checkAccess())() Check that the current context is trusted to modify the logging configuration. |
| static [LogManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html) | [getLogManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#getLogManager())() Returns the global LogManager object. |
| [Logger](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Logger.html) | [getLogger](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#getLogger(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Method to find a named logger. |
| [Enumeration](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Enumeration.html)\<[String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)\> | [getLoggerNames](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#getLoggerNames())() Get an enumeration of known logger names. |
| synchronized static [LoggingMXBean](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LoggingMXBean.html) | [getLoggingMXBean](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#getLoggingMXBean())() Returns LoggingMXBean for managing loggers. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getProperty](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#getProperty(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Get the value of a logging property. |
| void | [readConfiguration](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#readConfiguration())() Reinitialize the logging properties and reread the logging configuration. |
| void | [readConfiguration](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#readConfiguration(java.io.InputStream))([InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) ins) Reinitialize the logging properties and reread the logging configuration from the given stream, which should be in java.util.Properties format. |
| void | [removePropertyChangeListener](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#removePropertyChangeListener(java.beans.PropertyChangeListener))([PropertyChangeListener](https://developers.google.com/j2objc/javadoc/jre/reference/java/beans/PropertyChangeListener.html) l) *This method is deprecated. The dependency on `PropertyChangeListener` creates a significant impediment to future modularization of the Java platform. This method will be removed in a future release. The global `LogManager` can detect changes to the logging configuration by overridding the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#readConfiguration()` method.* |
| void | [reset](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#reset())() Reset the logging configuration. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Constants

#### public static final [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**LOGGING_MXBEAN_NAME**

String representation of the `ObjectName` for the management interface
for the logging facility.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LoggingMXBean.html`
Constant Value: "java.util.logging:type=Logging"

## Protected Constructors

#### protected
**LogManager**
()

Protected constructor. This is protected so that container applications
(such as J2EE containers) can subclass the object. It is non-public as
it is intended that there only be one LogManager object, whose value is
retrieved by calling Logmanager.getLogManager.

## Public Methods

#### public boolean
**addLogger**
([Logger](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Logger.html) logger)

Add a named logger. This does nothing and returns false if a logger
with the same name is already registered.


The Logger factory methods call this method to register each
newly created Logger.


The application should retain its own reference to the Logger
object to avoid it being garbage collected. The LogManager
may only retain a weak reference.

##### Parameters

| logger | the new logger. |
|---|---|

##### Returns

- true if the argument logger was registered successfully, false if a logger of that name already exists.

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the logger name is null. |
|---|---|

#### public void
**addPropertyChangeListener**
([PropertyChangeListener](https://developers.google.com/j2objc/javadoc/jre/reference/java/beans/PropertyChangeListener.html) l)


**This method is deprecated.**   
The dependency on `PropertyChangeListener` creates a
significant impediment to future modularization of the Java
platform. This method will be removed in a future release.
The global `LogManager` can detect changes to the
logging configuration by overridding the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#readConfiguration()` method.

Adds an event listener to be invoked when the logging
properties are re-read. Adding multiple instances of
the same event Listener results in multiple entries
in the property event listener table.

**WARNING:** This method is omitted from this class in all subset
Profiles of Java SE that do not include the `java.beans` package.

<br />

##### Parameters

| l | event listener |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the PropertyChangeListener is null. |
|---|---|

#### public void
**checkAccess**
()

Check that the current context is trusted to modify the logging
configuration. This requires LoggingPermission("control").


If the check fails we throw a SecurityException, otherwise
we return normally.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

#### public static [LogManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html)
**getLogManager**
()

Returns the global LogManager object.

##### Returns

- the global LogManager object

#### public [Logger](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Logger.html)
**getLogger**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Method to find a named logger.


Note that since untrusted code may create loggers with
arbitrary names this method should not be relied on to
find Loggers for security sensitive logging.
It is also important to note that the Logger associated with the
String `name` may be garbage collected at any time if there
is no strong reference to the Logger. The caller of this method
must check the return value for null in order to properly handle
the case where the Logger has been garbage collected.

<br />

##### Parameters

| name | name of the logger |
|---|---|

##### Returns

- matching logger or null if none is found

#### public [Enumeration](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Enumeration.html)\<[String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)\>
**getLoggerNames**
()

Get an enumeration of known logger names.


Note: Loggers may be added dynamically as new classes are loaded.
This method only reports on the loggers that are currently registered.
It is also important to note that this method only returns the name
of a Logger, not a strong reference to the Logger itself.
The returned String does nothing to prevent the Logger from being
garbage collected. In particular, if the returned name is passed
to `LogManager.getLogger()`, then the caller must check the
return value from `LogManager.getLogger()` for null to properly
handle the case where the Logger has been garbage collected in the
time since its name was returned by this method.

<br />

##### Returns

- enumeration of logger name strings

#### public static synchronized [LoggingMXBean](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LoggingMXBean.html)
**getLoggingMXBean**
()

Returns LoggingMXBean for managing loggers.

##### Returns

- a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LoggingMXBean.html` object.

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getProperty**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Get the value of a logging property.
The method returns null if the property is not found.

##### Parameters

| name | property name |
|---|---|

##### Returns

- property value

#### public void
**readConfiguration**
()

Reinitialize the logging properties and reread the logging configuration.


The same rules are used for locating the configuration properties
as are used at startup. So normally the logging properties will
be re-read from the same file that was used at startup.


Any log level definitions in the new configuration file will be
applied using Logger.setLevel(), if the target Logger exists.


A PropertyChangeEvent will be fired after the properties are read.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if there are IO problems reading the configuration. |
|---|---|

#### public void
**readConfiguration**
([InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) ins)

Reinitialize the logging properties and reread the logging configuration
from the given stream, which should be in java.util.Properties format.
A PropertyChangeEvent will be fired after the properties are read.


Any log level definitions in the new configuration file will be
applied using Logger.setLevel(), if the target Logger exists.

##### Parameters

| ins | stream to read properties from |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if there are problems reading from the stream. |
|---|---|

#### public void
**removePropertyChangeListener**
([PropertyChangeListener](https://developers.google.com/j2objc/javadoc/jre/reference/java/beans/PropertyChangeListener.html) l)


**This method is deprecated.**   
The dependency on `PropertyChangeListener` creates a
significant impediment to future modularization of the Java
platform. This method will be removed in a future release.
The global `LogManager` can detect changes to the
logging configuration by overridding the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogManager.html#readConfiguration()` method.

Removes an event listener for property change events.
If the same listener instance has been added to the listener table
through multiple invocations of `addPropertyChangeListener`,
then an equivalent number of
`removePropertyChangeListener` invocations are required to remove
all instances of that listener from the listener table.


Returns silently if the given listener is not found.

**WARNING:** This method is omitted from this class in all subset
Profiles of Java SE that do not include the `java.beans` package.

<br />

##### Parameters

| l | event listener (can be null) |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

#### public void
**reset**
()

Reset the logging configuration.


For all named loggers, the reset operation removes and closes
all Handlers and (except for the root logger) sets the level
to null. The root logger's level is set to Level.INFO.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|