de.fhg.igd.logging
Class LoggerFactory

java.lang.Object
  extended byde.fhg.igd.logging.LoggerFactory

public class LoggerFactory
extends Object

This factory knows how to create new, and dynamically update already deployed Logger objects depending on the currently chosen underlying logging mechanism. getLogger() or getLogger(String) respectively are intended to be called in order to request Logger instances.

Version:
"$Id: LoggerFactory.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Field Summary
static String AUTO_LOGGER
          The identifier for automatic detection of the logging mechanism
protected static List logger_priorities_
          The priority list of underlying logging mechanisms
protected static String PKG_PREFIX_
          The package prefix
static String PROPERTIES_RESOURCE
          The factory properties resource file
static String PROPERTY_LOGGER_PRIORITIES
          The name of the logger priorities property within the resource file
private static Set proxies_
          The storage for all deployed LoggerProxy objects
protected static Class wclazz_
          The current wrapper class (will be initialized along with LoggingConfiguration)
 
Constructor Summary
private LoggerFactory()
          Hidden unused construction.
 
Method Summary
protected static void changeLogger(String logger)
          Change the underlying logging mechanism and implicitly update all deployed proxies.
protected static void dismissProxy(LoggerProxy proxy)
          Remove a proxy from the cache.
private static Class findWrapperClass(String logger)
          Find the corresponding Wrapper implementation class for the given underlying logging mechanism.
static Logger getLogger()
          Get a ready-to-use groupless logger object.
static Logger getLogger(String group)
          Get a ready-to-use logger object with the specified group name.
protected static String underlyingLoggingMechanism()
          Get the short name of the underlying logging mechanism (as it is expected in LoggingConfiguration.setLogger(String)) that is currently in use.
protected static void updateProxies()
          Update proxies in case a better matching target is available.
private static void updateProxies(Class wclazz, boolean exchange)
          Perform an update of proxy targets, either in case of a logger change, when all deployed instances definitely need to be exchanged, or in case a better match may be available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_RESOURCE

public static final String PROPERTIES_RESOURCE
The factory properties resource file

See Also:
Constant Field Values

PROPERTY_LOGGER_PRIORITIES

public static final String PROPERTY_LOGGER_PRIORITIES
The name of the logger priorities property within the resource file

See Also:
Constant Field Values

AUTO_LOGGER

public static final String AUTO_LOGGER
The identifier for automatic detection of the logging mechanism

See Also:
Constant Field Values

PKG_PREFIX_

protected static final String PKG_PREFIX_
The package prefix

See Also:
Constant Field Values

proxies_

private static Set proxies_
The storage for all deployed LoggerProxy objects


logger_priorities_

protected static List logger_priorities_
The priority list of underlying logging mechanisms


wclazz_

protected static Class wclazz_
The current wrapper class (will be initialized along with LoggingConfiguration)

Constructor Detail

LoggerFactory

private LoggerFactory()
Hidden unused construction.

Method Detail

getLogger

public static Logger getLogger()
Get a ready-to-use groupless logger object.

Returns:
The groupless logger

getLogger

public static Logger getLogger(String group)
Get a ready-to-use logger object with the specified group name.

Parameters:
group - The logger's group name
Returns:
The logger
Throws:
IllegalArgumentException - if the group is null

underlyingLoggingMechanism

protected static String underlyingLoggingMechanism()
Get the short name of the underlying logging mechanism (as it is expected in LoggingConfiguration.setLogger(String)) that is currently in use.

Returns:
The name of the currently used underlying logging mechanism

updateProxies

protected static void updateProxies()
Update proxies in case a better matching target is available.


updateProxies

private static void updateProxies(Class wclazz,
                                  boolean exchange)
Perform an update of proxy targets, either in case of a logger change, when all deployed instances definitely need to be exchanged, or in case a better match may be available. However, the actual update will not be applied before all new target loggers were successfully created. As soon as the creation of a new target fails, already created targets will be dismissed and the configuration will be left untouched.

Parameters:
wclazz - The currently matching Wrapper class
exchange - true if targets should get exchanged in any case after the underlying logging mechanism has been exchanged, otherwise only if there is a better matching target available
Throws:
LoggingException - in case one of the new targets could not be created

changeLogger

protected static void changeLogger(String logger)
Change the underlying logging mechanism and implicitly update all deployed proxies.

Parameters:
logger - The name of the new underlying logging mechanism

findWrapperClass

private static Class findWrapperClass(String logger)
Find the corresponding Wrapper implementation class for the given underlying logging mechanism.

Parameters:
logger - The name of underlying logging mechanism
Returns:
The Wrapper implemenatation class for the given underlying logging mechanism
Throws:
LoggingException - in case the requested underlying logging mechanism is not available

dismissProxy

protected static void dismissProxy(LoggerProxy proxy)
Remove a proxy from the cache. This method will be called implicitely by whenever the garbage collector calls LoggerProxy.finalize().

Parameters:
proxy - The proxy to be dismissed


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.