|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--com.ls.service.log.log4j.Logger4j
This class is responsible for the logging of activities of agents and generates log entries. This class uses Log4J (http://jakarta.apache.org/log4j).
| Fields inherited from interface com.ls.service.log.ILogger |
ERROR, INFO, LEVEL_INDEPENDENT, LOG_LEVEL, MAX_LOG_LEVEL, TAG_GLOBAL_LOG_PATH, TAG_LOG_FILE, TAG_LOG_LEVEL, TAG_LOG_TYPE, TRACE, TRACE1, TRACE2, TRACE3, TRACE4, TRACE5, WARNING |
| Constructor Summary | |
Logger4j()
Empty constructor. |
|
Logger4j(String logFileName,
int logLevel,
Map map)
Constructor that includes trying to open the file where the log messages get stored and setting the log level. |
|
Logger4j(String logFileName,
Map map)
Constructor that includes trying to open the file where the log messages get stored. |
|
| Method Summary | |
boolean |
canLog(int logLevel)
determines, if a notice with the given log level will be logged |
void |
closeLogFile()
closes the logfile |
protected void |
finalize()
closes the log file if this object gets deleted |
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 log type of this logger. |
String |
getLogTypeString()
Returns the log type of this logger, as a string |
boolean |
hasLogFile()
Checks, if this Logger4j 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. Example: [31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message |
void |
log(String className,
int logLevel,
String methodName,
Object[] logNotice,
Throwable throwable)
Logs a given notice, if the given logLevel is equal or more important than the configured agent log level. Example: [31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message |
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. Example: [31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message |
void |
log(String className,
int logLevel,
String methodName,
String logNotice,
Throwable throwable)
Logs a given notice, if the given logLevel is equal or more important than the configured agent log level. Example: [31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message |
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. Example: [31-Jul-00 09:20:13.560] [error] [AgentDemo] [demoMethod()] ^^^ java.lang.NumberFormatException: null at java.lang.Long.parseLong(Long.java:284) at java.lang.Long. |
void |
logSystemInformation()
calls logSystemInformation on all configured system error log implementations and logs the output with log level ILogger.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. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Logger4j()
setLogFile(java.lang.String) method is not called).
Note: variable substitution for logfile names cannot work the way you expect (e.g. exchanging $A
with the agents' name) as long as you do not call replacementMapPutAll().
public Logger4j(String logFileName,
Map map)
logFileName - name of the log filemap - a Map containing variable/value pairs needed for variable substitution in log file names
(e.g. for exchanging $A with the agent's name)
public Logger4j(String logFileName,
int logLevel,
Map map)
logFileName - name of the log filelogLevel - determines which messages should be loggedmap - a Map containing variable/value pairs needed for variable substitution in log file names
(e.g. for exchanging $A with the agent's name)| Method Detail |
public void closeLogFile()
closeLogFile in interface ILoggercom.ls.service.log.ILoggerLogException - If any error occures while closing the log filepublic void logSystemInformation()
ILogger.LEVEL_INDEPENDENT to this log filelogSystemInformation in interface ILoggerLoggerFactory.clearSystemErrorLogs(),
LoggerFactory.addSystemErrorLog(ISystemErrorLog),
LoggerFactory.getSystemErrorLogNames()public boolean canLog(int logLevel)
canLog in interface ILoggerlogLevel - log level to compare against the configured log level
public void log(String className,
int logLevel,
String methodName,
Throwable throwable)
[31-Jul-00 09:20:13.560] [error] [AgentDemo] [demoMethod()] ^^^ java.lang.NumberFormatException: null at java.lang.Long.parseLong(Long.java:284) at java.lang.Long.(Long.java:526) at com.ls.lars2.AgentDemo.demoMethod(AgentDemo.java:230) at com.ls.lars2.AgentDemo.interpret(AgentDemo.java:174) at com.ls.lars2.AgentTemplate.executeConfigFileInterpretation(AgentTemplate.java, Compiled Code) at com.ls.lars2.AgentTemplate.run(AgentTemplate.java, Compiled Code)
log in interface ILoggerclassName - Name of the class in which the log message was createdlogLevel - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets
logged or ignoredmethodName - Name of the method in which the log message was createdthrowable - Throwable (Exception or Error) that should be logged
public void log(String className,
int logLevel,
String methodName,
String logNotice)
[31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message
log in interface ILoggerclassName - Name of the class in which the logMessage was createdlogLevel - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets
logged or ignoredmethodName - Name of the method in which the logMessage was createdlogNotice - Content of the logMessage
public void log(String className,
int logLevel,
String methodName,
Object[] logNotice)
[31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message
log in interface ILoggerclassName - Name of the class in which the logMessage was createdlogLevel - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets
logged or ignoredmethodName - Name of the method in which the logMessage was createdlogNotice - Content of the logMessage
public void log(String className,
int logLevel,
String methodName,
String logNotice,
Throwable throwable)
[31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message
log in interface ILoggerclassName - Name of the class in which the logMessage was createdlogLevel - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets
logged or ignoredmethodName - Name of the method in which the logMessage was createdlogNotice - Content of the logMessagethrowable - Throwable (Exception or Error) that should be logged
public void log(String className,
int logLevel,
String methodName,
Object[] logNotice,
Throwable throwable)
[31-Jul-00 09:20:13.560] [warning] [AgentDemo] [demoMethod()] this is a great warning log message
log in interface ILoggerclassName - Name of the class in which the logMessage was createdlogLevel - level of the message (ILogger.TRACE5 ... ILogger.ERROR) determining, if the notice gets
logged or ignoredmethodName - Name of the method in which the logMessage was createdlogNotice - Content of the logMessagethrowable - Throwable (Exception or Error) that should be loggedprotected void finalize()
finalize in class Objectpublic void replacementMapPutAll(Map map)
replacementMapPutAll in interface ILoggermap - a Map containing replacement variables as keys and replacements as valuesHashMap.putAll(Map)public void setLogLevel(int logLevel)
setLogLevel in interface ILoggerlogLevel - log level as an integer (use defined constants like ILogger.WARNING)
public void setLogLevel(String logLevel)
throws LogException
setLogLevel in interface ILoggerlogLevel - name of one of the defined constants (e.g. "error"), case is ignoredLogException - If given log level is null or unknownLoggerFactory.translateLogLevel(String)public int getLogLevel()
getLogLevel in interface ILoggerpublic String getLogLevelString()
getLogLevelString in interface ILoggerpublic boolean setLogFile(String logFileName)
setLogFile in interface ILoggerlogFileName - name of the file to be used as log filepublic boolean hasLogFile()
hasLogFile in interface ILoggerpublic String getLogFileName()
getLogFileName in interface ILoggerpublic void logThreadName(boolean loggingThreadName)
logThreadName in interface ILoggerloggingThreadName - specifies if the name of the thread is gona be loggedpublic byte getLogType()
getLogType in interface ILoggerpublic String getLogTypeString()
getLogTypeString in interface ILogger
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||