com.ls.service.log
Interface ILogger

All Known Implementing Classes:
Logger4j, Logger

public interface ILogger

Interface file for all log algorithms.

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

Field Summary
static int ERROR
          Declares a log message as an error.
static int INFO
          Declares a log message as a programmer's information for the log file reader.
static int LEVEL_INDEPENDENT
          Declares a log message as to be logged always (independent of the configured log level).
static String[] LOG_LEVEL
          contains the (lower case) names of the log levels starting with "error" and ending with "trace5"
static int MAX_LOG_LEVEL
          least important log level (the one, which produces the most log messages)
static String TAG_GLOBAL_LOG_PATH
          defines the global log path tag for configuration files
static String TAG_LOG_FILE
          defines the log file tag for configuration files
static String TAG_LOG_LEVEL
          defines the log level tag for configuration files
static String TAG_LOG_TYPE
          defines the log type tag for configuration files
static int TRACE
          same as TRACE1, remains for compatibility reasons only
static int TRACE1
          declares a log message as a debug information of trace level 1 (most important trace level)
static int TRACE2
          declares a log message as a debug information of trace level 2
static int TRACE3
          declares a log message as a debug information of trace level 3
static int TRACE4
          declares a log message as a debug information of trace level 4
static int TRACE5
          declares a log message as a debug information of trace level 5 (least important trace level)
static int WARNING
          Declares a log message as a warning.
 
Method Summary
 boolean canLog(int logLevel)
          determines, if a notice with the given log level will be logged
 void closeLogFile()
          Closes the log file.
 String getLogFileName()
          gets name of log file, which is currently in use
 int getLogLevel()
          Returns the current loglevel as number.
 String getLogLevelString()
          Returns gets the name of the current log level.
 byte getLogType()
          Returns the current logging type as a byte.
 String getLogTypeString()
          Returns the name of current logging type as a String ('LARS' or 'LOG4J').
 boolean hasLogFile()
          Checks, if this Logger instance uses a log file or System.out for logging.
 void log(String className, int logLevel, String methodName, Object[] logNotice)
          Logs a given notice, if the given logLevel is equal or more important than the configured agent log level.
 void log(String className, int logLevel, String methodName, Object[] logNotice, Throwable throwable)
          Logs a given notice and a throwable (Exception or Error) including a stack trace, if the given logLevel is equal or more important than the configured agent log level.
 void log(String className, int logLevel, String methodName, String logNotice)
          Logs a given notice, if the given logLevel is equal or more important than the configured agent log level.
 void log(String className, int logLevel, String methodName, String logNotice, Throwable throwable)
          Logs a given notice and a throwable (Exception or Error) including a stack trace, if the given logLevel is equal or more important than the configured agent log level.
 void log(String className, int logLevel, String methodName, Throwable throwable)
          Logs a throwable (Exception or Error) including a stack trace, if the given logLevel is equal or more important than the configured agent log level.
 void logSystemInformation()
          calls logSystemInformation on all configured system error log implementations and logs the output with log level LEVEL_INDEPENDENT to this log file
 void logThreadName(boolean loggingThreadName)
          turns on or off the thread name specification
 void replacementMapPutAll(Map map)
          Puts map to the replacement map, which is used for exchanging variables in a logfile's name with values (for example replace $A with the name of the owning agent).
 boolean setLogFile(String logFileName)
          changes the log file to another file
 void setLogLevel(int logLevel)
          Sets the agent's log level.
 void setLogLevel(String logLevel)
          Sets the agent's log level.
 

Field Detail

LEVEL_INDEPENDENT

public static final int LEVEL_INDEPENDENT
Declares a log message as to be logged always (independent of the configured log level). Examples for using this log level:

ERROR

public static final int ERROR
Declares a log message as an error. Examples for using this log level:

WARNING

public static final int WARNING
Declares a log message as a warning. This log level should be used, if something erroneous happened, that was expected by the programmer, and can be managed by the application (by performing some default actions or throwing an exception). Nethertheless the programmer wants to warn the log file reader about the reason for the default actions resp. the thrown exception.

INFO

public static final int INFO
Declares a log message as a programmer's information for the log file reader. Examples for using this log level:

TRACE

public static final int TRACE
same as TRACE1, remains for compatibility reasons only

TRACE1

public static final int TRACE1
declares a log message as a debug information of trace level 1 (most important trace level)

TRACE2

public static final int TRACE2
declares a log message as a debug information of trace level 2

TRACE3

public static final int TRACE3
declares a log message as a debug information of trace level 3

TRACE4

public static final int TRACE4
declares a log message as a debug information of trace level 4

TRACE5

public static final int TRACE5
declares a log message as a debug information of trace level 5 (least important trace level)

MAX_LOG_LEVEL

public static final int MAX_LOG_LEVEL
least important log level (the one, which produces the most log messages)

LOG_LEVEL

public static final String[] LOG_LEVEL
contains the (lower case) names of the log levels starting with "error" and ending with "trace5"

TAG_LOG_FILE

public static final String TAG_LOG_FILE
defines the log file tag for configuration files

TAG_LOG_TYPE

public static final String TAG_LOG_TYPE
defines the log type tag for configuration files

TAG_LOG_LEVEL

public static final String TAG_LOG_LEVEL
defines the log level tag for configuration files

TAG_GLOBAL_LOG_PATH

public static final String TAG_GLOBAL_LOG_PATH
defines the global log path tag for configuration files
Method Detail

log

public void log(String className,
                int logLevel,
                String methodName,
                Throwable throwable)
Logs a throwable (Exception or Error) including a stack trace, if the given logLevel is equal or more important than the configured agent log level.
Parameters:
className - Name of the class in which the log message was created
logLevel - 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) that should be logged

log

public void log(String className,
                int logLevel,
                String methodName,
                String logNotice)
Logs a given notice, if the given logLevel is equal or more important than the configured agent log level.
Parameters:
className - Name of the class in which the logMessage was created
logLevel - 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 logMessage

log

public void log(String className,
                int logLevel,
                String methodName,
                Object[] logNotice)
Logs a given notice, if the given logLevel is equal or more important than the configured agent log level.
Parameters:
className - Name of the class in which the logMessage was created
logLevel - 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 logMessage

log

public void log(String className,
                int logLevel,
                String methodName,
                String logNotice,
                Throwable throwable)
Logs a given notice and a throwable (Exception or Error) including a stack trace, if the given logLevel is equal or more important than the configured agent log level.
Parameters:
className - name of the class in which the log message was created
logLevel - level of the message (Logger.TRACE5 ... Logger.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) that should be logged

log

public void log(String className,
                int logLevel,
                String methodName,
                Object[] logNotice,
                Throwable throwable)
Logs a given notice and a throwable (Exception or Error) including a stack trace, if the given logLevel is equal or more important than the configured agent log level.
Parameters:
className - name of the class in which the log message was created
logLevel - level of the message (Logger.TRACE5 ... Logger.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) that should be logged

replacementMapPutAll

public void replacementMapPutAll(Map map)
Puts map to the replacement map, which is used for exchanging variables in a logfile's name with values (for example replace $A with the name of the owning agent).
Note: The new key/value pairs will not be used until the next log file is opened!
Parameters:
map - a Map containing replacement variables as keys and replacements as values
See Also:
HashMap.putAll(Map)

getLogType

public byte getLogType()
Returns the current logging type as a byte.
Returns:
The current logType

getLogTypeString

public String getLogTypeString()
Returns the name of current logging type as a String ('LARS' or 'LOG4J').
Returns:
The name of the current logType ('LARS' or 'LOG4J').

setLogLevel

public void setLogLevel(int logLevel)
Sets the agent's log level. The agent's log level is used to specify if message of a cretain level has to be logged: If the log level of a log message is at least as important the agent'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 void setLogLevel(String logLevel)
                 throws LogException
Sets the agent's log level. The agent's log level is used to specify if message of a cretain level has to be logged: If the log level of a log message is at least as important the agent'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 int getLogLevel()
Returns the current loglevel as number.
Returns:
The current loglevel

getLogLevelString

public String getLogLevelString()
Returns gets the name of the current log level.
Returns:
Name of the current loglevel

setLogFile

public boolean setLogFile(String logFileName)
changes the log file to another file
Parameters:
logFileName - name of the file to be used as log file
Returns:
false, if the new log file could not be opened or the old one could not be closed; true else

getLogFileName

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

closeLogFile

public void closeLogFile()
                  throws LogException
Closes the log file.
Throws:
LogException - If any error occures while closing the log file

hasLogFile

public boolean hasLogFile()
Checks, if this Logger instance uses a log file or System.out for logging.
Returns:
true, if a log file is in use; false if System.out is in use

canLog

public boolean canLog(int logLevel)
determines, 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

logSystemInformation

public void logSystemInformation()
calls logSystemInformation on all configured system error log implementations and logs the output with log level LEVEL_INDEPENDENT to this log file

logThreadName

public void logThreadName(boolean loggingThreadName)
turns on or off the thread name specification
Parameters:
loggingThreadName - specifies if the name of the thread is gona be logged