FileDocCategorySizeDatePackage
LogHelper.javaAPI DocGlassfish v2 API4750Fri May 04 22:35:24 BST 2007com.sun.jdo.spi.persistence.utility.logging

LogHelper

public class LogHelper extends Object
This class manages the logging facility for JDO components. It is the class that keeps track of the log factory in use for getting loggers for use in JDO components.

This class has no JDK 1.4 dependencies.

The log factory is responsible for constructing the loggers and for ensuring that there is only one logger per component.

author
Craig Russell
version
1.0

Fields Summary
protected static boolean
jdk14
Flag to tell we are running in JDK 1.4 and can use java.util.logging.Logger implementation.
protected static LoggerFactory
loggerFactory
LoggerFactory registered for creating new loggers.
Constructors Summary
Methods Summary
public static synchronized LoggergetLogger(java.lang.String loggerName, java.lang.String bundleName, java.lang.ClassLoader loader)
Get a Logger. This call is delegated to the registered LoggerFactory. If there is no registered LoggerFactory, then initialize one based on whether we are running in JDK 1.4 (or higher). The bundle name and class loader are passed to allow the implementation to properly find and construct the internationalization bundle. This method is synchronized to avoid race conditions where two threads access a component using the same Logger at the same time.

param
loggerName the relative name of this logger
param
bundleName the fully qualified name of the resource bundle
param
loader the class loader used to load the resource bundle, or null
return
the logger

    
                                                                                                                      
              
        // if an implementation has not registered a LoggerFactory, use a standard one.
        if (loggerFactory == null) {
            if (jdk14) {
                loggerFactory = new LoggerFactoryJDK14();
            } else {
                loggerFactory = new LoggerFactoryJDK13();
            }
        }
        return loggerFactory.getLogger(loggerName, bundleName, loader);
    
public static booleanisJDK14()
Check to see if the JDK 1.4 logging environment is available.

return
true if JDK 1.4 logging is available

        try {
            Class logger = Class.forName("java.util.logging.Logger"); //NOI18N
            return true;
        } catch (ClassNotFoundException ex) {
            return false;
        }
    
public static voidregisterLoggerFactory(LoggerFactory factory)
Register a LoggerFactory for use in managed environments or for special situations. This factory will be delegated to for all getLogger requests.

param
factory the LoggerFactory to use for all getLogger requests

        loggerFactory = factory;