edu.isi.pegasus.common.logging.logger
Class Log4j

java.lang.Object
  extended by edu.isi.pegasus.common.logging.LogManager
      extended by edu.isi.pegasus.common.logging.logger.Log4j

public class Log4j
extends LogManager

A Log4j implementation of the LogManager interface. Using this allows us us log messages using Log4j

Version:
$Revision: 2567 $
Author:
Karan Vahi

Field Summary
private static String LOG4J_CONF_PROPERTY
          The property that specifies the path to the log4j properties file.
private  org.apache.log4j.Logger mLogger
          The handle to a log4j logger object.
private  Properties mProperties
          The properties passed at runtime
private static org.apache.log4j.Logger mRoot
          Keeps track of log4j's root logger as singleton.
 
Fields inherited from class edu.isi.pegasus.common.logging.LogManager
CONFIG_MESSAGE_LEVEL, CONSOLE_MESSAGE_LEVEL, DEBUG_MESSAGE_LEVEL, DEFAULT_LOGGER, ERROR_MESSAGE_LEVEL, FATAL_MESSAGE_LEVEL, INFO_MESSAGE_LEVEL, LOG4J_LOGGER, mDebugLevel, MESSAGE_DONE_PREFIX, mLogFormatter, PROPERTIES_PREFIX, TRACE_MESSAGE_LEVEL, VERSION, WARNING_MESSAGE_LEVEL
 
Constructor Summary
Log4j()
          The constructor.
 
Method Summary
 int getLevel()
          Returns the debug level.
 void initialize(LogFormatter formatter, Properties properties)
          Sets the log formatter to use for formatting the messages.
 void log(String message, Exception e, int level)
          Logs the exception on the appropriate queue if the level of the message is less than or equal to the level set for the Logger.
protected  void logAlreadyFormattedMessage(String message, int level)
          Logs the message on the appropriate queue if the level of the message is less than or equal to the level set for the Logger.
 void logEntityHierarchyMessage(String parentType, String parentID, String childIDType, Collection<String> childIDs)
          Log a message that connects the parent entities with the children.
 void logEventCompletion(int level)
          Logs the completion message on the basis of the debug level.
 void setLevel(int level)
          Sets the debug level.
protected  void setLevel(int level, boolean info)
          Sets the debug level.
 void setLevel(org.apache.log4j.Level level)
          Sets the debug level.
protected  void setLevel(org.apache.log4j.Level level, boolean info)
          Sets the debug level.
 void setWriters(String out)
          Sets both the output writer and the error writer to the same underlying writer.
 
Methods inherited from class edu.isi.pegasus.common.logging.LogManager
add, add, getInstance, log, log, logAndReset, logEntityHierarchyMessage, logEventCompletion, logEventStart, logEventStart, logEventStart, logEventStart, sanityCheckOnDirectory, sanityCheckOnFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG4J_CONF_PROPERTY

private static final String LOG4J_CONF_PROPERTY
The property that specifies the path to the log4j properties file.

See Also:
Constant Field Values

mLogger

private org.apache.log4j.Logger mLogger
The handle to a log4j logger object.


mRoot

private static org.apache.log4j.Logger mRoot
Keeps track of log4j's root logger as singleton.


mProperties

private Properties mProperties
The properties passed at runtime

Constructor Detail

Log4j

public Log4j()
The constructor.

Method Detail

initialize

public void initialize(LogFormatter formatter,
                       Properties properties)
Sets the log formatter to use for formatting the messages.

Specified by:
initialize in class LogManager
Parameters:
formatter - the formatter to use.
properties - properties that the underlying implementations understand

logEntityHierarchyMessage

public void logEntityHierarchyMessage(String parentType,
                                      String parentID,
                                      String childIDType,
                                      Collection<String> childIDs)
Log a message that connects the parent entities with the children. For e.g. can we use to create the log messages connecting the jobs with the workflow they are part of. They are by default logged to INFO level

Overrides:
logEntityHierarchyMessage in class LogManager
Parameters:
parentType - the type of parent entity
parentID - the id of the parent entity
childIDType - the type of children entities
childIDs - Collection of children id's

setLevel

public void setLevel(org.apache.log4j.Level level)
Sets the debug level. All those messages are logged which have a level less than equal to the debug level.

Overrides:
setLevel in class LogManager
Parameters:
level - the level to which the debug level needs to be set to.

setLevel

public void setLevel(int level)
Sets the debug level. All those messages are logged which have a level less than equal to the debug level. In addition the info messages are always logged.

Overrides:
setLevel in class LogManager
Parameters:
level - the level to which the debug level needs to be set to.

setLevel

protected void setLevel(int level,
                        boolean info)
Sets the debug level. All those messages are logged which have a level less than equal to the debug level. In case the boolean info is set, all the info messages are also logged.

Specified by:
setLevel in class LogManager
Parameters:
level - the level to which the debug level needs to be set to.
info - boolean denoting whether the INFO messages need to be logged or not.

setLevel

protected void setLevel(org.apache.log4j.Level level,
                        boolean info)
Sets the debug level. All those messages are logged which have a level less than equal to the debug level. In case the boolean info is set, all the info messages are also logged.

Parameters:
level - the level to which the debug level needs to be set to.
info - boolean denoting whether the INFO messages need to be logged or not.

getLevel

public int getLevel()
Returns the debug level.

Specified by:
getLevel in class LogManager
Returns:
the level to which the debug level has been set to.

setWriters

public void setWriters(String out)
Sets both the output writer and the error writer to the same underlying writer.

Specified by:
setWriters in class LogManager
Parameters:
out - is the name of a file to append to. Special names are stdout and stderr, which map to the system's respective streams.

log

public void log(String message,
                Exception e,
                int level)
Logs the exception on the appropriate queue if the level of the message is less than or equal to the level set for the Logger. For INFO level message, the boolean indicating that a completion message is to follow is set to true always.

Specified by:
log in class LogManager
Parameters:
message - the message to be logged.
e - the exception to be logged
level - the level on which the message has to be logged.
See Also:
setLevel(int), LogManager.log(String,int)

logAlreadyFormattedMessage

protected void logAlreadyFormattedMessage(String message,
                                          int level)
Logs the message on the appropriate queue if the level of the message is less than or equal to the level set for the Logger. For INFO level message, the boolean indicating that a completion message is to follow is set to true always.

Specified by:
logAlreadyFormattedMessage in class LogManager
Parameters:
message - the message to be logged.
level - the level on which the message has to be logged.
See Also:
setLevel(int)

logEventCompletion

public void logEventCompletion(int level)
Logs the completion message on the basis of the debug level.

Specified by:
logEventCompletion in class LogManager
Parameters:
level - the debug level of the start message for whose completion you want.


Copyright © 2011 The University of Southern California. All Rights Reserved.