Java Doc for LogManager.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » logging » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util.logging 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.logging.LogManager

LogManager
public class LogManager (Code)
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.

By default, the LogManager reads its initial configuration from a properties file "lib/logging.properties" in the JRE directory. If you edit that property file you can change the default logging configuration for all uses of that JRE.

In addition, the LogManager uses two optional system properties that allow more control over reading the initial configuration:

  • "java.util.logging.config.class"
  • "java.util.logging.config.file"
These two properties may be set via the Preferences API, or as command line property definitions 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, as described above, the LogManager will read its initial configuration from a properties file "lib/logging.properties" in the JRE 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.
version:
   1.60, 05/18/07
since:
   1.4



Field Summary
final public static  StringLOGGING_MXBEAN_NAME
     String representation of the javax.management.ObjectName for LoggingMXBean .

Constructor Summary
protected  LogManager()
     Protected constructor.

Method Summary
public synchronized  booleanaddLogger(Logger logger)
     Add a named logger.
public  voidaddPropertyChangeListener(PropertyChangeListener l)
     Adds an event listener to be invoked when the logging properties are re-read.
public  voidcheckAccess()
     Check that the current context is trusted to modify the logging configuration.
synchronized  LoggerdemandLogger(String name)
    
 booleangetBooleanProperty(String name, boolean defaultValue)
    
 FiltergetFilterProperty(String name, Filter defaultValue)
    
 FormattergetFormatterProperty(String name, Formatter defaultValue)
    
 intgetIntProperty(String name, int defaultValue)
    
 LevelgetLevelProperty(String name, Level defaultValue)
    
public static  LogManagergetLogManager()
     Return the global LogManager object.
public synchronized  LoggergetLogger(String name)
     Method to find a named logger.
public synchronized  Enumeration<String>getLoggerNames()
     Get an enumeration of known logger names.
public static synchronized  LoggingMXBeangetLoggingMXBean()
     Returns LoggingMXBean for managing loggers.
public  StringgetProperty(String name)
     Get the value of a logging property.
 StringgetStringProperty(String name, String defaultValue)
    
public  voidreadConfiguration()
     Reinitialize the logging properties and reread the logging configuration.

The same rules are used for locating the configuration properties as are used at startup.

public  voidreadConfiguration(InputStream ins)
     Reinitialize the logging properties and reread the logging configuration from the given stream, which should be in java.util.Properties format.
public  voidremovePropertyChangeListener(PropertyChangeListener l)
     Removes an event listener for property change events.
public  voidreset()
     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.


Field Detail
LOGGING_MXBEAN_NAME
final public static String LOGGING_MXBEAN_NAME(Code)
String representation of the javax.management.ObjectName for LoggingMXBean .
since:
   1.5




Constructor Detail
LogManager
protected LogManager()(Code)
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.




Method Detail
addLogger
public synchronized boolean addLogger(Logger logger)(Code)
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. true if the argument logger was registered successfully,false if a logger of that name already exists.
exception:
  NullPointerException - if the logger name is null.




addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l) throws SecurityException(Code)
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.
Parameters:
  l - event listener
exception:
  SecurityException - if a security manager exists and ifthe caller does not have LoggingPermission("control").
exception:
  NullPointerException - if the PropertyChangeListener is null.



checkAccess
public void checkAccess() throws SecurityException(Code)
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.
exception:
  SecurityException - if a security manager exists and ifthe caller does not have LoggingPermission("control").




demandLogger
synchronized Logger demandLogger(String name)(Code)



getBooleanProperty
boolean getBooleanProperty(String name, boolean defaultValue)(Code)



getFilterProperty
Filter getFilterProperty(String name, Filter defaultValue)(Code)



getFormatterProperty
Formatter getFormatterProperty(String name, Formatter defaultValue)(Code)



getIntProperty
int getIntProperty(String name, int defaultValue)(Code)



getLevelProperty
Level getLevelProperty(String name, Level defaultValue)(Code)



getLogManager
public static LogManager getLogManager()(Code)
Return the global LogManager object.



getLogger
public synchronized Logger getLogger(String name)(Code)
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.


Parameters:
  name - name of the logger matching logger or null if none is found




getLoggerNames
public synchronized Enumeration<String> getLoggerNames()(Code)
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.

enumeration of logger name strings




getLoggingMXBean
public static synchronized LoggingMXBean getLoggingMXBean()(Code)
Returns LoggingMXBean for managing loggers. The LoggingMXBean can also obtained from the java.lang.management.ManagementFactory.getPlatformMBeanServerplatform MBeanServer method. a LoggingMXBean object.
See Also:   java.lang.management.ManagementFactory
since:
   1.5



getProperty
public String getProperty(String name)(Code)
Get the value of a logging property. The method returns null if the property is not found.
Parameters:
  name - property name property value



getStringProperty
String getStringProperty(String name, String defaultValue)(Code)



readConfiguration
public void readConfiguration() throws IOException, SecurityException(Code)
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.
exception:
  SecurityException - if a security manager exists and ifthe caller does not have LoggingPermission("control").
exception:
  IOException - if there are IO problems reading the configuration.




readConfiguration
public void readConfiguration(InputStream ins) throws IOException, SecurityException(Code)
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
exception:
  SecurityException - if a security manager exists and ifthe caller does not have LoggingPermission("control").
exception:
  IOException - if there are problems reading from the stream.




removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l) throws SecurityException(Code)
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.
Parameters:
  l - event listener (can be null)
exception:
  SecurityException - if a security manager exists and ifthe caller does not have LoggingPermission("control").




reset
public void reset() throws SecurityException(Code)
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.
exception:
  SecurityException - if a security manager exists and ifthe caller does not have LoggingPermission("control").




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.