com.ls.service.log
Class SystemLogger

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

public final class SystemLogger
extends Object

Agents not contained in the com.ls.lars package are not allowed to use this class, but should use an instance of ILogger. Due to downward compatibility reasons this is not forced, but only solicited.

This class is responsible for the logging of activities of components contained in the com.ls.lars package. There exist 8 different log levels: error (most important), warning, info and five different trace levels (trace1, .., trace5). It depends on the log level of the message and on the system's log level, if a log message gets written: If the log level of the message is at least as important as the system's log level, the message is written, otherwise it is ignored.
The log message gets written in a log file, if such a logfile got specified and opened successfully afterwards - else the log messages are written to System.out. Specifying and opening a log file can be done in with help of the setLogFile(java.lang.String) method.

Note: None of the methods are synchronized, because internally AgentLog is used for logging and the critical sections are synchronized there!

Agents not contained in the com.ls.lars package are not allowed to use this class, but should use an instance of ILogger. Due to downward compatibility reasons this is not forced, but only solicited.

Version:
$Revision: 1.11 $
Author:
Last modified by $Author: MFehrenbach $

Constructor Summary
SystemLogger()
           
 
Method Summary
static boolean canLog(int logLevel)
          detemines, if a notice with the given log level will be logged
static String getLogFileName()
          gets name of logfile, which is currently in use
static ILogger getLogger()
          returns the reference of ILogger used from SystemLogger
static int getLogLevel()
          Returns the current loglevel as number.
static String getLogLevelString()
          Returns gets the name of the current log level.
static byte getLogType()
          returns the type of the logger
static void log(ILogger additionalLogger, String className, int logType, String methodName, Object[] logNotice)
          Logs a given notice, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, int logType, String methodName, Object[] logNotice, Throwable throwable)
          Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, int logType, String methodName, String logNotice)
          Logs a given notice, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, int logType, String methodName, String logNotice, Throwable throwable)
          Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, int logType, String methodName, Throwable throwable)
          Logs a given exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, String componentName, int logType, String methodName, Object[] logNotice)
          Logs a given notice, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, String componentName, int logType, String methodName, Object[] logNotice, Throwable throwable)
          Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, String componentName, int logType, String methodName, String logNotice)
          Logs a given notice, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, String componentName, int logType, String methodName, String logNotice, Throwable throwable)
          Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(ILogger additionalLogger, String className, String componentName, int logType, String methodName, Throwable throwable)
          Logs a given exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(String className, int logType, String methodName, Object[] logNotice)
          Writes a log message, if the given logType is equal or more important than the configured system log level.
static void log(String className, int logType, String methodName, Object[] logNotice, Throwable throwable)
          Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(String className, int logType, String methodName, String logNotice)
          Writes a log message, if the given logType is equal or more important than the configured system log level.
static void log(String className, int logType, String methodName, String logNotice, Throwable throwable)
          Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(String className, int logType, String methodName, Throwable throwable)
          Logs an exception including its stack trace, if the given logType is equal or more important than the configured system log level.
static void log(String className, String componentName, int logType, String methodName, Object[] logNotice)
          Writes a log message (the logging component is identified with help of the componentName!)
static void log(String className, String componentName, int logType, String methodName, Object[] logNotice, Throwable throwable)
          Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(String className, String componentName, int logType, String methodName, String logNotice)
          Writes a log message (the logging component is identified with help of the componentName!)
static void log(String className, String componentName, int logType, String methodName, String logNotice, Throwable throwable)
          Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
static void log(String className, String componentName, int logType, String methodName, Throwable throwable)
          Logs an exception including its stack trace, if the given logType is equal or more important than the configured system log level.
static void logSystemInformation()
          logs system dependant information with help of ILogger.logSystemInformation() into the system's log file
static boolean setLogFile(String logFileName)
          changes the log file to another file
static void setLogLevel(int logLevel)
          Sets the system's log level.
static void setLogLevel(String logLevel)
          Sets the system's log level.
static void setLogType(byte logType)
          Changes the type of the logger with the type of logger specified as a parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemLogger

public SystemLogger()
Method Detail

setLogLevel

public static void setLogLevel(int logLevel)
Sets the system's log level. The system's log level is used to specify if message of a certain log level has to be logged: If the log level of a log message is at least as important the system's log level, the message is written, otherwise it is ignored.
Parameters:
logLevel - log level as an integer (use defined constants like ILogger.WARNING)

setLogLevel

public static void setLogLevel(String logLevel)
                        throws LogException
Sets the system's log level. The system's log level is used to specify if message of a certain log level has to be logged: If the log level of a log message is at least as important the system's log level, the message is written, otherwise it is ignored.
Parameters:
logLevel - name of one of the defined constants (e.g. "error"), case is ignored
Throws:
LogException - If given log level is null or unknown

getLogLevel

public static int getLogLevel()
Returns the current loglevel as number. Example: 0=ERROR, 1=WARNING, 2=INFO, 3=TRACE ...
Returns:
The current loglevel

getLogLevelString

public static String getLogLevelString()
Returns gets the name of the current log level. Example: ERROR, WARNING, INFO, TRACE ....
Returns:
Name of the current loglevel

getLogger

public static ILogger getLogger()
returns the reference of ILogger used from SystemLogger
Returns:
reference to the log object

setLogType

public static void setLogType(byte logType)
                       throws LogException
Changes the type of the logger with the type of logger specified as a parameter.
Parameters:
logType - the new type of the logging system
Throws:
LogException - If any error occurs

getLogType

public static byte getLogType()
returns the type of the logger
Returns:
the seted log type

setLogFile

public static boolean setLogFile(String logFileName)
changes the log file to another file
Parameters:
logFileName - name of the file to be used as log file
Returns:
true, if changing the logfile was successful; false else

getLogFileName

public static String getLogFileName()
gets name of logfile, which is currently in use
Returns:
log file's name or "System.out", if no log file is in use

logSystemInformation

public static void logSystemInformation()
logs system dependant information with help of ILogger.logSystemInformation() into the system's log file

canLog

public static boolean canLog(int logLevel)
detemines, if a notice with the given log level will be logged
Parameters:
logLevel - log level to compare against the configured log level
Returns:
true, if the given logLevel is equal or more important than the configured agent log level; false else

log

public static void log(String className,
                       int logType,
                       String methodName,
                       String logNotice)
Writes a log message, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the logMessage was created
logNotice - content of the log message

log

public static void log(String className,
                       String componentName,
                       int logType,
                       String methodName,
                       String logNotice)
Writes a log message (the logging component is identified with help of the componentName!), if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
componentName - name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

log

public static void log(String className,
                       int logType,
                       String methodName,
                       Object[] logNotice)
Writes a log message, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the logMessage was created
logNotice - content of the log message

log

public static void log(String className,
                       String componentName,
                       int logType,
                       String methodName,
                       Object[] logNotice)
Writes a log message (the logging component is identified with help of the componentName!), if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
componentName - name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

log

public static void log(ILogger additionalLogger,
                       String className,
                       String componentName,
                       int logType,
                       String methodName,
                       String logNotice)
Logs a given notice, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
componentName - string that identifies the logging component (usually the thread name)
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

log

public static void log(ILogger additionalLogger,
                       String className,
                       int logType,
                       String methodName,
                       String logNotice)
Logs a given notice, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

log

public static void log(ILogger additionalLogger,
                       String className,
                       String componentName,
                       int logType,
                       String methodName,
                       Object[] logNotice)
Logs a given notice, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
componentName - string that identifies the logging component (usually the thread name)
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

log

public static void log(ILogger additionalLogger,
                       String className,
                       int logType,
                       String methodName,
                       Object[] logNotice)
Logs a given notice, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

log

public static void log(String className,
                       String componentName,
                       int logType,
                       String methodName,
                       String logNotice,
                       Throwable throwable)
Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
componentName - name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(String className,
                       int logType,
                       String methodName,
                       String logNotice,
                       Throwable throwable)
Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(String className,
                       String componentName,
                       int logType,
                       String methodName,
                       Object[] logNotice,
                       Throwable throwable)
Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
componentName - name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(String className,
                       int logType,
                       String methodName,
                       Object[] logNotice,
                       Throwable throwable)
Writes a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(ILogger additionalLogger,
                       String className,
                       String componentName,
                       int logType,
                       String methodName,
                       String logNotice,
                       Throwable throwable)
Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
componentName - Name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(ILogger additionalLogger,
                       String className,
                       int logType,
                       String methodName,
                       String logNotice,
                       Throwable throwable)
Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(ILogger additionalLogger,
                       String className,
                       String componentName,
                       int logType,
                       String methodName,
                       Object[] logNotice,
                       Throwable throwable)
Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
componentName - Name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(ILogger additionalLogger,
                       String className,
                       int logType,
                       String methodName,
                       Object[] logNotice,
                       Throwable throwable)
Logs a given notice and an exception including a stack trace, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(String className,
                       int logType,
                       String methodName,
                       Throwable throwable)
Logs an exception including its stack trace, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the logMessage was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(String className,
                       String componentName,
                       int logType,
                       String methodName,
                       Throwable throwable)
Logs an exception including its stack trace, if the given logType is equal or more important than the configured system log level.
Parameters:
className - name of the class in which the logMessage was created
componentName - name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(ILogger additionalLogger,
                       String className,
                       String componentName,
                       int logType,
                       String methodName,
                       Throwable throwable)
Logs a given exception including a stack trace, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the logMessage was created
componentName - name of the component in which the log message was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
throwable - Throwable (Exception or Error) which should be logged

log

public static void log(ILogger additionalLogger,
                       String className,
                       int logType,
                       String methodName,
                       Throwable throwable)
Logs a given exception including a stack trace, if the given logType is equal or more important than the configured system log level. The notice is written to the configured system log file (may be System.out) and to the given logger - but to the latter one only, if the logger is not logging to System.out.
This method is used e.g. in the AgentTemplate, where logging messages in the agent's own logfile and in the systems log file makes sense, because the AgentTemplate is a "core" class of the system (therefore the messages belong in the system's log file) and the log messages should help to explain the behaviour of a specific agent (therefore the messages belong in the agent's log file).
Parameters:
additionalLogger - log file of the agent (that owns the logging component) where the same log message (with the same log level) should be logged
className - name of the class in which the logMessage was created
logType - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
throwable - Throwable (Exception or Error) which should be logged