com.sibvisions.util.log
Class LoggerFactory

java.lang.Object
  extended by com.sibvisions.util.log.LoggerFactory
Direct Known Subclasses:
JdkLoggerFactory

public abstract class LoggerFactory
extends Object

The LoggerFactory is a factory for creating ILogger instances, for the configured log technology. To use the configured log factory implement the following call in your starter:

LoggerFactory.init("com.package.log.MyLoggerFactory");

Later you can create an ILogger instance and use it as follows:

ILogger logger = LoggerFactory.getInstance("com.project.MyWindow");
logger.debug("My first log message!");
.


Constructor Summary
protected LoggerFactory()
          Invisible constructor, because the LoggerFactory is a utility class.
 
Method Summary
abstract  ILogger createLogger(String pName)
          Gets an ILogger.
static ILogger getInstance(Class pClass)
          Construct (if necessary) and return an ILogger instance, using the factory's current set of configuration attributes.
static ILogger getInstance(String pName)
          Construct (if necessary) and return an ILogger instance, using the factory's current set of configuration attributes.
static ILogger.LogLevel getLevel(Class pClass)
          Gets the level of a specific logger.
static ILogger.LogLevel getLevel(String pName)
          Gets the level of a specific logger.
static List<ILogger> getLogger()
          Gets all created logger instances.
abstract  void init()
          Initializes the factory instance.
static void init(String pClassName)
          Creates a new instance of LoggerFactory.
static void setLevel(Class pClass, ILogger.LogLevel pLevel)
          Sets the level of a specific logger.
static void setLevel(String pName, ILogger.LogLevel pLevel)
          Sets the level of a specific logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerFactory

protected LoggerFactory()
Invisible constructor, because the LoggerFactory is a utility class.

Method Detail

createLogger

public abstract ILogger createLogger(String pName)
Gets an ILogger.

Parameters:
pName - the name for which a logger should be returned/created
Returns:
the ILogger implementation

init

public abstract void init()
Initializes the factory instance.


init

public static void init(String pClassName)
Creates a new instance of LoggerFactory. If the pClassName was not found then the JdkLoggerFactory will be instantiated.

Parameters:
pClassName - the log factory implementation

getInstance

public static ILogger getInstance(Class pClass)
Construct (if necessary) and return an ILogger instance, using the factory's current set of configuration attributes.

Parameters:
pClass - the class for which a logger should be returned/created
Returns:
the logger for the specified class
Throws:
RuntimeException - if the log factory was not initialized
See Also:
getInstance(String)

getInstance

public static ILogger getInstance(String pName)
Construct (if necessary) and return an ILogger instance, using the factory's current set of configuration attributes.

Parameters:
pName - the name for which a logger should be returned/created
Returns:
the logger for the specified class
Throws:
RuntimeException - if the log factory was not initialized

setLevel

public static void setLevel(Class pClass,
                            ILogger.LogLevel pLevel)
Sets the level of a specific logger.

Parameters:
pClass - the class
pLevel - the log level

setLevel

public static void setLevel(String pName,
                            ILogger.LogLevel pLevel)
Sets the level of a specific logger.

Parameters:
pName - the logger name
pLevel - the log level

getLevel

public static ILogger.LogLevel getLevel(Class pClass)
Gets the level of a specific logger.

Parameters:
pClass - the class
Returns:
the log level

getLevel

public static ILogger.LogLevel getLevel(String pName)
Gets the level of a specific logger.

Parameters:
pName - the logger name
Returns:
the log level

getLogger

public static List<ILogger> getLogger()
Gets all created logger instances.

Returns:
an enumeration with ILoggers


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.