org.openuat.log
Class LogFactory

java.lang.Object
  extended by org.openuat.log.LogFactory
Direct Known Subclasses:
BandyFactory, Log4jFactory, MicrologFactory

public abstract class LogFactory
extends java.lang.Object

The public interface of this class provides the two static methods init and getLogger, which conveniently allow to receive a suitable logger for the current system. It is important that init is called before the first call to getLogger, else it will return a default empty logger that just does nothing.
Usage and code example:
Initialize the LogFactory in the applications main class, e.g. in the class inheriting from MIDlet (J2ME) or the class containing the main method (J2SE):

 LogFactory.init(new Log4jFactory());
 
or
 LogFactory.init(new MicrologFactory());
 
Then you can obtain a Log instance in any other class with:
 Log logger = LogFactory.getLogger("my.named.logger");
 

Version:
1.0
Author:
Lukas Huser
See Also:
Log

Constructor Summary
LogFactory()
           
 
Method Summary
static Log getLogger(java.lang.String name)
          Requests a logger from the underlying logging framework and returns it, wrapped in a Log instance.
static void init(LogFactory FactoryInstance)
          Initializes the LogFactory.
protected abstract  Log newLogger(java.lang.String name)
          Creates a new wrapper around a logger from the underlying logging framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogFactory

public LogFactory()
Method Detail

init

public static void init(LogFactory FactoryInstance)
Initializes the LogFactory.
This method should be called only once, at application startup, and before any calls to getLogger.

Parameters:
FactoryInstance - a new LogFactory instance. It is always an instance of a subclass of LogFactory, since LogFactory itself is abstract.

getLogger

public static Log getLogger(java.lang.String name)
Requests a logger from the underlying logging framework and returns it, wrapped in a Log instance.

Parameters:
name - The name of the requested logger.
Returns:
The requested named logger or the default empty logger if LogFactory has not been initialized.

newLogger

protected abstract Log newLogger(java.lang.String name)
Creates a new wrapper around a logger from the underlying logging framework.

Parameters:
name - The name of the new logger.
Returns:
The


2005-2009, Rene Mayrhofer.