Class 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 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
    • Constructor Detail

      • Log4j

        public Log4j()
        The constructor.
    • Method Detail

      • initialize

        public void initialize​(LogFormatter formatter,
                               java.util.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​(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:
        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​(java.lang.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​(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:
        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​(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:
        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.