Class Log4j
- java.lang.Object
-
- edu.isi.pegasus.common.logging.LogManager
-
- 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$
- Author:
- Karan Vahi
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringLOG4J_CONF_PROPERTYThe property that specifies the path to the log4j properties file.private org.apache.log4j.LoggermLoggerThe handle to a log4j logger object.private java.util.PropertiesmPropertiesThe properties passed at runtimeprivate static org.apache.log4j.LoggermRootKeeps 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
Constructors Constructor Description Log4j()The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetLevel()Returns the debug level.voidinitialize(LogFormatter formatter, java.util.Properties properties)Sets the log formatter to use for formatting the messages.voidlog(java.lang.String message, java.lang.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 voidlogAlreadyFormattedMessage(java.lang.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.voidlogEntityHierarchyMessage(java.lang.String parentType, java.lang.String parentID, java.lang.String childIDType, java.util.Collection<java.lang.String> childIDs)Log a message that connects the parent entities with the children.voidlogEventCompletion(int level)Logs the completion message on the basis of the debug level.voidsetLevel(int level)Sets the debug level.protected voidsetLevel(int level, boolean info)Sets the debug level.voidsetLevel(org.apache.log4j.Level level)Sets the debug level.protected voidsetLevel(org.apache.log4j.Level level, boolean info)Sets the debug level.voidsetWriters(java.lang.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
-
-
-
-
Field Detail
-
LOG4J_CONF_PROPERTY
private static final java.lang.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 java.util.Properties mProperties
The properties passed at runtime
-
-
Method Detail
-
initialize
public void initialize(LogFormatter formatter, java.util.Properties properties)
Sets the log formatter to use for formatting the messages.- Specified by:
initializein classLogManager- Parameters:
formatter- the formatter to use.properties- properties that the underlying implementations understand
-
logEntityHierarchyMessage
public void logEntityHierarchyMessage(java.lang.String parentType, java.lang.String parentID, java.lang.String childIDType, java.util.Collection<java.lang.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:
logEntityHierarchyMessagein classLogManager- Parameters:
parentType- the type of parent entityparentID- the id of the parent entitychildIDType- the type of children entitieschildIDs- 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:
setLevelin classLogManager- 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:
setLevelin classLogManager- 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:
setLevelin classLogManager- 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:
getLevelin classLogManager- Returns:
- the level to which the debug level has been set to.
-
setWriters
public void setWriters(java.lang.String out)
Sets both the output writer and the error writer to the same underlying writer.- Specified by:
setWritersin classLogManager- Parameters:
out- is the name of a file to append to. Special names arestdoutandstderr, which map to the system's respective streams.
-
log
public void log(java.lang.String message, java.lang.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:
login classLogManager- Parameters:
message- the message to be logged.e- the exception to be loggedlevel- the level on which the message has to be logged.- See Also:
setLevel(int),LogManager.log(String,int)
-
logAlreadyFormattedMessage
protected void logAlreadyFormattedMessage(java.lang.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:
logAlreadyFormattedMessagein classLogManager- 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:
logEventCompletionin classLogManager- Parameters:
level- the debug level of the start message for whose completion you want.
-
-