com.sibvisions.util.log
Class LoggerFactory

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

public abstract class LoggerFactory
extends java.lang.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!");
.


Field Summary
static java.lang.String LOGFACTORY_DEFAULT
          the constant name for the default logger factory implementation.
 
Constructor Summary
protected LoggerFactory()
          Invisible constructor, because the LoggerFactory is a utility class.
 
Method Summary
abstract  ILogger createLogger(java.lang.String pName)
          Creates an ILogger.
static void destroy()
          Destroys the internal cache and logging configuration.
static ILogger getInstance(java.lang.Class pClass)
          Construct (if necessary) and return an ILogger instance, using the factory's current set of configuration attributes.
static ILogger getInstance(java.lang.String pName)
          Construct (if necessary) and return an ILogger instance, using the factory's current set of configuration attributes.
static ILogger.LogLevel getLevel(java.lang.Class pClass)
          Gets the level of a specific logger.
static ILogger.LogLevel getLevel(java.lang.String pName)
          Gets the level of a specific logger.
static java.util.List<ILogger> getLogger()
          Gets all created logger instances.
abstract  void init()
          Initializes the factory instance.
static void init(java.lang.String pClassName)
          Creates a new instance of LoggerFactory.
protected  boolean isInitDone()
          Gets whether factory is initialized.
static boolean isInitialized()
          Gets whether this factory has been initialized.
static void setLevel(java.lang.Class pClass, ILogger.LogLevel pLevel)
          Sets the level of a specific logger.
static void setLevel(java.lang.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
 

Field Detail

LOGFACTORY_DEFAULT

public static final java.lang.String LOGFACTORY_DEFAULT
the constant name for the default logger factory implementation.

See Also:
Constant Field Values
Constructor Detail

LoggerFactory

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

Method Detail

createLogger

public abstract ILogger createLogger(java.lang.String pName)
Creates 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(java.lang.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

isInitialized

public static boolean isInitialized()
Gets whether this factory has been initialized.

Returns:
true if already initialized, false otherwise

destroy

public static void destroy()
Destroys the internal cache and logging configuration.


getInstance

public static ILogger getInstance(java.lang.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:
java.lang.RuntimeException - if the log factory was not initialized
See Also:
getInstance(String)

getInstance

public static ILogger getInstance(java.lang.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:
java.lang.RuntimeException - if the log factory was not initialized

setLevel

public static void setLevel(java.lang.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(java.lang.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(java.lang.Class pClass)
Gets the level of a specific logger.

Parameters:
pClass - the class
Returns:
the log level

getLevel

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

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

getLogger

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

Returns:
an enumeration with ILoggers

isInitDone

protected boolean isInitDone()
Gets whether factory is initialized.

Returns:
true in any case because only init() creates a new factory instance


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.