java.util.logging
Class LogManager
The
LogManager
maintains a hierarchical namespace
of Logger objects and manages properties for configuring the logging
framework. There exists only one single
LogManager
per virtual machine. This instance can be retrieved using the
static method
getLogManager()
.
Configuration Process: The global LogManager
object is created and configured when the class
java.util.logging.LogManager
is initialized.
The configuration process includes the subsequent steps:
- If the system property
java.util.logging.manager
is set to the name of a subclass of
java.util.logging.LogManager
, an instance of
that subclass is created and becomes the global LogManager.
Otherwise, a new instance of LogManager is created. - The
LogManager
constructor tries to create
a new instance of the class specified by the system
property java.util.logging.config.class
.
Typically, the constructor of this class will call
LogManager.getLogManager().readConfiguration(java.io.InputStream)
for configuring the logging framework.
The configuration process stops at this point if
the system property java.util.logging.config.class
is set (irrespective of whether the class constructor
could be called or an exception was thrown). - If the system property
java.util.logging.config.class
is not set, the configuration parameters are read in from
a file and passed to
readConfiguration(InputStream)
.
The name and location of this file are specified by the system
property java.util.logging.config.file
. - If the system property
java.util.logging.config.file
is not set, however, the contents of the URL
"{gnu.classpath.home.url}/logging.properties" are passed to
readConfiguration(InputStream)
.
Here, "{gnu.classpath.home.url}" stands for the value of
the system property gnu.classpath.home.url
.
The
LogManager
has a level of
INFO
by
default, and this will be inherited by
Logger
s unless they
override it either by properties or programmatically.
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
LOGGING_MXBEAN_NAME
public static final String LOGGING_MXBEAN_NAME
The object name for the logging management bean.
- "java.util.logging:type=Logging"
LogManager
protected LogManager()
The basic constructor. Object is special, because it has no
superclass, so there is no call to super().
addLogger
public boolean addLogger(Logger logger)
Adds a named logger. If a logger with the same name has
already been registered, the method returns
false
without adding the logger.
The
LogManager
only keeps weak references
to registered loggers. Therefore, names can become available
after automatic garbage collection.
logger
- the logger to be added.
true
if logger
was added,
false
otherwise.
checkAccess
public void checkAccess()
throws SecurityException
Checks whether the current security context allows changing
the configuration of the logging framework. For the security
context to be trusted, it has to be granted
a LoggingPermission("control").
SecurityException
- if a security manager exists and
the caller is not granted the permission to control
the logging infrastructure.
getLogger
public Logger getLogger(String name)
Returns a Logger given its name.
name
- the name of the logger.
- a named Logger, or
null
if there is no
logger with that name.
getLoggerNames
public Enumeration getLoggerNames()
Returns an Enumeration of currently registered Logger names.
Since other threads can register loggers at any time, the
result could be different any time this method is called.
- an Enumeration with the names of the currently
registered Loggers.
readConfiguration
public void readConfiguration()
throws IOException,
SecurityException
Configures the logging framework by reading a configuration file.
The name and location of this file are specified by the system
property
java.util.logging.config.file
. If this
property is not set, the URL
"{gnu.classpath.home.url}/logging.properties" is taken, where
"{gnu.classpath.home.url}" stands for the value of the system
property
gnu.classpath.home.url
.
The task of configuring the framework is then delegated to
readConfiguration(InputStream)
, which will
notify registered listeners after having read the properties.
SecurityException
- if a security manager exists and
the caller is not granted the permission to control
the logging infrastructure, or if the caller is
not granted the permission to read the configuration
file.IOException
- if there is a problem reading in the
configuration file.
reset
public void reset()
throws SecurityException
Resets the logging configuration by removing all handlers for
registered named loggers and setting their level to null
.
The level of the root logger will be set to Level.INFO
.
SecurityException
- if a security manager exists and
the caller is not granted the permission to control
the logging infrastructure.
LogManager.java -- a class for maintaining Loggers and managing
configuration properties
Copyright (C) 2002, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.