com.ls.service.log
Class LoggerFactory

java.lang.Object
  |
  +--com.ls.service.log.LoggerFactory

public class LoggerFactory
extends Object

Factory class for the ones who implements ILogger. This has also required public static methods for global log path and system information.

Version:
$Revision: 1.10 $
Author:
Last modified by $Author: JBogenschuetz $

Field Summary
static byte LARS
          The type of the log will be LARS
static byte LOG4J
          The type of the log will be LOG4J
 
Constructor Summary
LoggerFactory()
           
 
Method Summary
static void addSystemErrorLog(ISystemErrorLog systemErrorLog)
          configures the LoggerFactory to use an additional system error log implementation
static void clearSystemErrorLogs()
          removes all configured system error log implementations
static byte getCodeOfLogType(String logTypeValue)
          Converts string name of the logger to the byte value, if the value is empty or it is null the defaultLogType of is return.
static byte getDefaultLogType()
          returns the default log type
static String getGlobalLogPath()
          Returns the path where the logfiles, that are not addressed via an absolute path, will be written.
static ILogger getInstance()
          returns an instance of ILogger, that is the defaut type of logger specified by the variable
static ILogger getInstance(byte logType)
          returns an instance of ILogger according to the parameter, in case the creation of the logger specified by the parameter fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
static ILogger getInstance(byte logType, String logFileName, int logLevel, Map map)
          returns an instance of ILogger according to the parameters, in case the creation of the logger specified by the logType fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
static ILogger getInstance(byte logType, String logFileName, Map map)
          returns an instance of ILogger according to the parameters, in case the creation of the logger specified by the logType fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
static ILogger getInstance(byte logType, String logFileName, String logLevel, Map map)
          returns an instance of ILogger according to the parameters, in case the creation of the logger specified by the logType fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
static String getStringOfLogType(byte logTypeValue)
          Converts byte value of the logger to the string name
static Set getSystemErrorLogNames()
          gets the name of all configured system error log implementations
static Set getSystemErrorLogSet()
          gets the system error local set variable
static void setDefaultLogType(byte newLogType)
          sets the default log type of the logger to the value specified as a parameter
static void setGlobalLogPath(String path)
          Sets the path where the log files, that are not addressed via an absolute path, will be written.
static int translateLogLevel(String logLevel)
          translates a log level from a String to an int
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LARS

public static final byte LARS
The type of the log will be LARS

LOG4J

public static final byte LOG4J
The type of the log will be LOG4J
Constructor Detail

LoggerFactory

public LoggerFactory()
Method Detail

getInstance

public static ILogger getInstance()
                           throws BaseRuntimeException
returns an instance of ILogger, that is the defaut type of logger specified by the variable
Returns:
instance user will get the instance of the class ILogger (specified by the variable
Throws:
BaseRuntimeException - If after the failure of creation of ILogger with the specifed log type and after it try, also, the creation of the ILogger wht the type=LARS
See Also:
getInstance(byte)

getInstance

public static ILogger getInstance(byte logType)
                           throws BaseRuntimeException
returns an instance of ILogger according to the parameter, in case the creation of the logger specified by the parameter fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
Parameters:
logType - requested logging mechanism (LARS or LOG4J)
Returns:
instance user will get the instance of the class ILogger
Throws:
BaseRuntimeException - If after the failure of creation of ILogger with the specifed log type and after it try, also, the creation of the ILogger wht the type=LARS

getInstance

public static ILogger getInstance(byte logType,
                                  String logFileName,
                                  Map map)
                           throws BaseRuntimeException
returns an instance of ILogger according to the parameters, in case the creation of the logger specified by the logType fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
Parameters:
logType - requested logging mechanism (LARS or LOG4J)
logFileName - name of the log file
map - a Map containing variable/value pairs needed for variable substitution in log file names (e.g. for exchanging $A with the agent's name)
Returns:
instance User will get the instance of the class ILogger
Throws:
BaseRuntimeException - If after the failure of creation of ILogger with the specifed log type and after it try, also, the creation of the ILogger wht the type=LARS

getInstance

public static ILogger getInstance(byte logType,
                                  String logFileName,
                                  int logLevel,
                                  Map map)
                           throws BaseRuntimeException
returns an instance of ILogger according to the parameters, in case the creation of the logger specified by the logType fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
Parameters:
logType - requested logging mechanism (LARS or LOG4J)
logFileName - name of the log file
logLevel - determines which messages should be logged
map - a Map containing variable/value pairs needed for variable substitution in log file names (e.g. for exchanging $A with the agent's name)
Returns:
instance User will get the instance of the class ILogger
Throws:
BaseRuntimeException - If after the failure of creation of ILogger with the specifed log type and after it try, also, the creation of the ILogger wht the type=LARS

getInstance

public static ILogger getInstance(byte logType,
                                  String logFileName,
                                  String logLevel,
                                  Map map)
                           throws BaseRuntimeException
returns an instance of ILogger according to the parameters, in case the creation of the logger specified by the logType fails try to create the the logger with the type of 'LARS', if this fails than it is thrown an BaseRuntimeException.
Parameters:
logType - requested logging mechanism (LARS or LOG4J)
logFileName - Name of the log file
logLevel - determines which messages should be logged (name of one of the defined constants (e.g. "error"), case is ignored)
map - a Map containing variable/value pairs needed for variable substitution in log file names (e.g. for exchanging $A with the agent's name)
Returns:
instance User will get the instance of the class ILogger
Throws:
BaseRuntimeException - If after the failure of creation of ILogger with the specifed log type and after it try, also, the creation of the ILogger wht the type=LARS
See Also:
getInstance(byte,String,int,Map)

translateLogLevel

public static int translateLogLevel(String logLevel)
                             throws LogException
translates a log level from a String to an int
Parameters:
logLevel - name of one of the defined constants (e.g. "error"), case is ignored
Returns:
The integer value of the log level statet in parameter
Throws:
LogException - If given log level is null or unknown

setGlobalLogPath

public static void setGlobalLogPath(String path)
                             throws ProgrammingException
Sets the path where the log files, that are not addressed via an absolute path, will be written.
Note: This method can be called for security reasons only once in a lifetime.
Parameters:
path - log file path
Throws:
ProgrammingException - If global log path was already set before

getGlobalLogPath

public static String getGlobalLogPath()
Returns the path where the logfiles, that are not addressed via an absolute path, will be written.
Returns:
logfile path (empty string, if none is configured)

addSystemErrorLog

public static void addSystemErrorLog(ISystemErrorLog systemErrorLog)
configures the LoggerFactory to use an additional system error log implementation
Parameters:
systemErrorLog - additional system error log implementation
See Also:
ILogger.logSystemInformation()

clearSystemErrorLogs

public static void clearSystemErrorLogs()
removes all configured system error log implementations
See Also:
ILogger.logSystemInformation()

getSystemErrorLogNames

public static Set getSystemErrorLogNames()
gets the name of all configured system error log implementations
Returns:
names of all configured system error log implementations
See Also:
ILogger.logSystemInformation()

getSystemErrorLogSet

public static Set getSystemErrorLogSet()
gets the system error local set variable
Returns:
the system error local set variable

getDefaultLogType

public static byte getDefaultLogType()
returns the default log type
Returns:
the default log type as a byte

setDefaultLogType

public static void setDefaultLogType(byte newLogType)
sets the default log type of the logger to the value specified as a parameter
Parameters:
newLogType - the new log type

getCodeOfLogType

public static byte getCodeOfLogType(String logTypeValue)
                             throws LogException
Converts string name of the logger to the byte value, if the value is empty or it is null the defaultLogType of is return.
Parameters:
logTypeValue - the string value of the log type
Returns:
The byte code of the log type
Throws:
LogException - If not a valid log type

getStringOfLogType

public static String getStringOfLogType(byte logTypeValue)
                                 throws LogException
Converts byte value of the logger to the string name
Parameters:
logTypeValue - the byte value of the log type
Returns:
The String name of the log type
Throws:
LogException - If not a valid log type