Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.adfnmc.java.util.logging
Class LogManager

java.lang.Object
  extended by oracle.adfnmc.java.util.logging.LogManager

public class LogManager
extends java.lang.Object

LogManager is used to manage named Loggers and any shared logging properties.

There is one global LogManager instance in the application, which can be obtained by calling the static method LogManager.getLogManager().

All methods on this type can be taken as being thread safe.

The LogManager class can be specified by the "java.util.logging.manager" system property. If the property is unavailable or invalid java.util.logging.LogManager will be used by default.

On initialization, LogManager reads its configuration data from a properties file, which by default is the "lib/logging.properties" file in the JRE directory.

However, two system properties can be used instead to customize the initialization of the LogManager:

These properties can be set either by using the Preferences API, as a command line option or by passing the appropriate system property definitions to JNI_CreateJavaVM.

The "java.util.logging.config.class" property should specify a class name. If it is set, this class will be loaded and instantiated during LogManager's initialization, so that this object's default constructor can read the initial configuration and define properties for the LogManager.

The "java.util.logging.config.file" system property can be used to specify a properties file if the "java.util.logging.config.class" property has not been used. This file will be read instead of the default properties file.

Some global logging properties are as follows:

Besides global properties, properties for individual Loggers and Handlers can be specified in the property files. The names of these properties will start with the fully qualified name of the handler or logger.

The LogManager organizes Loggers based on their fully qualified names. For example, "x.y.z" is child of "x.y".

Levels for Loggers can be defined by properties whose name end with ".level". For example, "alogger.level = 4" sets the level for the logger "alogger" to 4, Any children of "alogger" will also be given the level 4 unless specified lower down in the properties file. The property ".level" will set the log level for the root logger.


Field Summary
static java.lang.String LOGGING_MXBEAN_NAME
           The String value of the LoggingMXBean's ObjectName.
 
Constructor Summary
protected LogManager()
          Default constructor.
 
Method Summary
 boolean addLogger(Logger logger)
          Add a given logger into the hierarchical namespace.
 void checkAccess()
          Check that the caller has LoggingPermission("control") so that it is trusted to modify the configuration for logging framework.
 Logger getLogger(java.lang.String name)
          Get the logger with the given name
 java.util.Enumeration getLoggerNames()
          Get a Enumeration of all registered logger names
static LogManager getLogManager()
          Get the global LogManager instance
 java.lang.String getProperty(java.lang.String name)
          Get the value of property with given name
 void readConfiguration()
          Re-initialize the properties and configuration.
 void reset()
          Reset configuration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGING_MXBEAN_NAME

public static final java.lang.String LOGGING_MXBEAN_NAME

The String value of the LoggingMXBean's ObjectName.

See Also:
Constant Field Values
Constructor Detail

LogManager

protected LogManager()
Default constructor. This is not public because there should be only one LogManager instance, which can be get by LogManager.getLogManager(. This is protected so that application can subclass the object.

Method Detail

checkAccess

public void checkAccess()
Check that the caller has LoggingPermission("control") so that it is trusted to modify the configuration for logging framework. If the check passes, just return, otherwise SecurityException will be thrown.

Throws:
java.lang.SecurityException - if there is a security manager in operation and the invoker of this method does not have the required security permission LoggingPermission("control")

addLogger

public boolean addLogger(Logger logger)
Add a given logger into the hierarchical namespace. The Logger.addLogger() factory methods call this method to add newly created Logger. This returns false if a logger with the given name has existed in the namespace

Note that the LogManager may only retain weak references to registered loggers. In order to prevent Logger objects from being unexpectedly garbage collected it is necessary for applications to maintain references to them.

Parameters:
logger - the logger to be added
Returns:
true if the given logger is added into the namespace successfully, false if the logger of given name has existed in the namespace

getLogger

public Logger getLogger(java.lang.String name)
Get the logger with the given name

Parameters:
name - name of logger
Returns:
logger with given name, or null if nothing is found

getLoggerNames

public java.util.Enumeration getLoggerNames()
Get a Enumeration of all registered logger names

Returns:
enumeration of registered logger names

getLogManager

public static LogManager getLogManager()
Get the global LogManager instance

Returns:
the global LogManager instance

getProperty

public java.lang.String getProperty(java.lang.String name)
Get the value of property with given name

Parameters:
name - the name of property
Returns:
the value of property

readConfiguration

public void readConfiguration()
                       throws java.io.IOException
Re-initialize the properties and configuration. The initialization process is same as the LogManager instantiation.

A PropertyChangeEvent must be fired.

Throws:
java.io.IOException - if any IO related problems happened
java.lang.SecurityException - if security manager exists and it determines that caller does not have the required permissions to perform this action

reset

public void reset()
Reset configuration.

All handlers are closed and removed from any named loggers. All loggers' level is set to null, except the root logger's level is set to Level.INFO.

Throws:
java.lang.SecurityException - if security manager exists and it determines that caller does not have the required permissions to perform this action

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.