Class Log

  • All Implemented Interfaces:
    java.io.Serializable

    public class Log
    extends java.lang.Object
    implements java.io.Serializable
    The Log object is used to log messages to logs. It keeps a list of different Loggers, all implementing LogInterface, and asks all of them to log.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Log.InternalLogger
      A collection of loggers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean debug
      The debug mode flag for the log.
    • Constructor Summary

      Constructors 
      Constructor Description
      Log​(Log parentLog)
      A constructor taking another Log as a parameter.
      Log​(java.lang.String resourceName)
      A constructor which takes only a resource name.
      Log​(java.lang.String resourceName, Log.InternalLogger loggers)
      Deprecated. 
      Log​(java.lang.String resourceName, java.lang.String category)
      A constructor with both resourceName and category name
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLogger​(LogInterface logger)
      Add a LogInterface to internal list of loggers.
      void close()
      Close the output logger
      void debug​(java.lang.String res)
      Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged.
      void debug​(java.lang.String res, java.lang.Object param)
      Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged.
      void debug​(java.lang.String res, java.lang.Object[] params)
      Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged.
      void debug​(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
      Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged.
      void dump​(java.lang.Object o)
      This methods dumps an Object to the log file.
      void dumpEntry​(Entry e)
      Dumps a formatted message to the logfile from the contents of an Entry
      void error​(java.lang.String res)
      Log a message with error level.
      void error​(java.lang.String res, java.lang.Object[] params)
      Log a message with error level.
      void error​(java.lang.String res, java.lang.Object[] params, java.lang.Throwable error)
      Log a message with error level.
      void error​(java.lang.String res, java.lang.Object param, java.lang.Throwable error)
      Log a message with error level.
      void error​(java.lang.String res, java.lang.String param)
      Log a message with error level.
      void error​(java.lang.String res, java.lang.String param1, java.lang.String param2)
      Log a message with error level.
      void error​(java.lang.String res, java.lang.Throwable error)
      Log a message with error level.
      void exception​(java.lang.String res)
      Throws a new exception with a custom message.
      void exception​(java.lang.String res, java.lang.Object param)
      Throws a new exception with a custom message.
      void exception​(java.lang.String res, java.lang.Object[] params)
      Throws a new exception with a custom message.
      void exception​(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
      Throws a new exception with a custom message.
      void fatal​(java.lang.String res)
      Log a message with fatal level.
      void fatal​(java.lang.String res, java.lang.Object param)
      Log a message with fatal level.
      void fatal​(java.lang.String res, java.lang.Object[] params)
      Log a message with fatal level.
      void fatal​(java.lang.String res, java.lang.Object param, java.lang.Throwable err)
      Log a message with fatal level.
      void fatal​(java.lang.String res, java.lang.Throwable err)
      Log a message with fatal level.
      void fine​(java.lang.String res)
      Log a message with debug level.
      void fine​(java.lang.String res, java.lang.Object param)
      Log a message with debug level.
      void fine​(java.lang.String res, java.lang.Object[] params)
      Log a message with debug level.
      void fine​(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
      Log a message with debug level.
      java.lang.String getCategory()
      Returns the category for this Log
      LogInterface getClassLogger​(java.lang.String className)
      Returns a LogInterface with the given class Name.
      boolean getDebug()
      Return the value of the debug parameter
      java.util.Vector<org.apache.logging.log4j.Logger> getLoggers()
      Returns a Vector containing all org.apache.log4j.Logger objects used by this Log.
      java.lang.String getPrefix()
      Returns the prefix to be prepended to all messages
      java.lang.String getString​(java.lang.String resource)
      Return the NLS string given the resource.
      java.lang.String getString​(java.lang.String resource, java.lang.Object param)
      Return the NLS string given the resource and a parameter.
      java.lang.String getString​(java.lang.String resource, java.lang.Object[] params)
      Return the NLS string given the resource and an array of parameters
      java.lang.String getString​(java.lang.String resource, java.lang.Object param1, java.lang.Object param2)
      Return the NLS string given the resource and two parameters
      SystemLogAppender getSystemLog()
      Returns the SystemLogAppender if any, in the Log.
      TDILog4j getTDILog4j()
      Returns a TDILog4j Logger connected to this Log object.
      void info​(java.lang.String res)
      Log a message with info level.
      void info​(java.lang.String res, java.lang.Object param)
      Log a message with info level.
      void info​(java.lang.String res, java.lang.Object[] params)
      Log a message with info level.
      void info​(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
      Log a message with info level.
      boolean isDebugEnabled()
      Checks whether debug is enabled.
      static boolean isLoggingEnabled()
      Returns whether TDI logging is active or disabled.
      void log​(java.lang.String level, java.lang.String msg)
      Log a message with the specified level.
      void logdebug​(java.lang.String msg)
      Log a message with info level if the debug mode flag is true, otherwise an debug level message is logged.
      void logerror​(java.lang.String msg)
      Log a message with error level.
      void logerror​(java.lang.String msg, java.lang.Throwable error)
      Log a message with error level with an additional Throwable object.
      void logfatal​(java.lang.String msg)
      Log a message with fatal level.
      void logfine​(java.lang.String msg)
      Logs a message to the output stream.
      void loginfo​(java.lang.String msg)
      Log a message with info level.
      void logwarn​(java.lang.String msg)
      Log a message with warning level.
      void removeLogger​(LogInterface logger)
      Remove a LogInterface from the internal list of loggers.
      void setCategory​(java.lang.String category)
      Sets the category for this Log
      void setDebug​(boolean debug)
      Sets debug parameter
      static void setLoggingEnabled()
      Checks the com.ibm.di.logging.enabled property to see if logging is enabled
      static void setLoggingEnabled​(boolean enabled)
      Disables or enables TDI logging.
      void setPrefix​(java.lang.String prefix)
      Sets a prefix to be prepended to all messages
      void setSystemLogAppender​(SystemLogAppender tmp)  
      void warn​(java.lang.String res)
      Log a message with warning level.
      void warn​(java.lang.String res, java.lang.Object param)
      Log a message with warning level.
      void warn​(java.lang.String res, java.lang.Object[] params)
      Log a message with warning level.
      void warn​(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
      Log a message with warning level.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • debug

        public boolean debug
        The debug mode flag for the log.
    • Constructor Detail

      • Log

        public Log​(java.lang.String resourceName)
        A constructor which takes only a resource name.
        Parameters:
        resourceName - Name used both as translation resource name and the category name
      • Log

        public Log​(java.lang.String resourceName,
                   java.lang.String category)
        A constructor with both resourceName and category name
        Parameters:
        resourceName - Name used for locating translation resource
        category - The category name for the loggers
      • Log

        public Log​(Log parentLog)
        A constructor taking another Log as a parameter. All messages are logged to that Log's internal list of loggers.
        Parameters:
        parentLog - The other Log
      • Log

        @Deprecated
        public Log​(java.lang.String resourceName,
                   Log.InternalLogger loggers)
        Deprecated.
        A constructor with both resourceName and an InternalLogger
        Parameters:
        resourceName - Name used for locating translation resource
        loggers - Used as the list of loggers
    • Method Detail

      • getLoggers

        public java.util.Vector<org.apache.logging.log4j.Logger> getLoggers()
        Returns a Vector containing all org.apache.log4j.Logger objects used by this Log.
        Returns:
        a Vector containing all Logger objects used by this Log.
      • getSystemLog

        public SystemLogAppender getSystemLog()
        Returns the SystemLogAppender if any, in the Log.
        Returns:
      • addLogger

        public void addLogger​(LogInterface logger)
        Add a LogInterface to internal list of loggers.
        Parameters:
        logger - The new LogInterface object.
      • removeLogger

        public void removeLogger​(LogInterface logger)
        Remove a LogInterface from the internal list of loggers.
        Parameters:
        logger - The LogInterface object.
      • getTDILog4j

        public TDILog4j getTDILog4j()
        Returns a TDILog4j Logger connected to this Log object.
        Returns:
        the TDILog4j Logger
      • getClassLogger

        public LogInterface getClassLogger​(java.lang.String className)
                                    throws java.lang.Exception
        Returns a LogInterface with the given class Name. An instance is created and added to the internal list of loggers.
        Parameters:
        className - The class name
        Returns:
        a LogInterface with the given class Name.
        Throws:
        java.lang.Exception - if problem occurs
      • setDebug

        public void setDebug​(boolean debug)
        Sets debug parameter
        Parameters:
        debug - true if debug level should be output as info
      • getDebug

        public boolean getDebug()
        Return the value of the debug parameter
        Returns:
        the boolean value
      • isDebugEnabled

        public boolean isDebugEnabled()
        Checks whether debug is enabled.
        Returns:
        true if the debug mode flag is true or any of the kept loggers has enabled debug, otherwise returns false.
      • setLoggingEnabled

        public static void setLoggingEnabled()
        Checks the com.ibm.di.logging.enabled property to see if logging is enabled
      • setLoggingEnabled

        public static void setLoggingEnabled​(boolean enabled)
        Disables or enables TDI logging. All loggers are affected by this setting.
        Parameters:
        enabled - if true all loggers are enabled, otherwise they are disabled
      • isLoggingEnabled

        public static boolean isLoggingEnabled()
        Returns whether TDI logging is active or disabled.
        Returns:
        true if logging is enabled, otherwise false
      • setCategory

        public void setCategory​(java.lang.String category)
        Sets the category for this Log
        Parameters:
        category - The category
        Since:
        7.0
      • getCategory

        public java.lang.String getCategory()
        Returns the category for this Log
        Returns:
        The category
        Since:
        7.0
      • setPrefix

        public void setPrefix​(java.lang.String prefix)
        Sets a prefix to be prepended to all messages
        Parameters:
        prefix -
      • getPrefix

        public java.lang.String getPrefix()
        Returns the prefix to be prepended to all messages
        Returns:
        the prefix
      • getString

        public java.lang.String getString​(java.lang.String resource)
        Return the NLS string given the resource.
        Parameters:
        resource - the given resource
        Returns:
        a NLS string
      • getString

        public java.lang.String getString​(java.lang.String resource,
                                          java.lang.Object param)
        Return the NLS string given the resource and a parameter.
        Parameters:
        resource - the given resource
        param - a parameter
        Returns:
        a NLS strings
      • getString

        public java.lang.String getString​(java.lang.String resource,
                                          java.lang.Object param1,
                                          java.lang.Object param2)
        Return the NLS string given the resource and two parameters
        Parameters:
        resource - the given resource
        param1 - a parameter
        param2 - a parameter
        Returns:
        a NLS strings
      • getString

        public java.lang.String getString​(java.lang.String resource,
                                          java.lang.Object[] params)
        Return the NLS string given the resource and an array of parameters
        Parameters:
        resource - the given resource
        params - an array of parameters
        Returns:
        a NLS strings
      • close

        public void close()
        Close the output logger
      • logfine

        public void logfine​(java.lang.String msg)
        Logs a message to the output stream.
        Parameters:
        msg - The message to log.
      • logdebug

        public void logdebug​(java.lang.String msg)
        Log a message with info level if the debug mode flag is true, otherwise an debug level message is logged. This is done for all used loggers.
        Parameters:
        msg - the message to log
      • loginfo

        public void loginfo​(java.lang.String msg)
        Log a message with info level. This is done for all used loggers.
        Parameters:
        msg - the message to log
      • logwarn

        public void logwarn​(java.lang.String msg)
        Log a message with warning level. This is done for all used loggers.
        Parameters:
        msg - the message to log
      • logerror

        public void logerror​(java.lang.String msg)
        Log a message with error level. This is done for all used loggers.
        Parameters:
        msg - the message to log
      • logerror

        public void logerror​(java.lang.String msg,
                             java.lang.Throwable error)
        Log a message with error level with an additional Throwable object. This is done for all used loggers.
        Parameters:
        msg - the message to log
        error - the Throwable to be logged
      • logfatal

        public void logfatal​(java.lang.String msg)
        Log a message with fatal level. This is done for all used loggers.
        Parameters:
        msg - the message to log
      • fine

        public void fine​(java.lang.String res)
        Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource given.
        Parameters:
        res - the resource used for the message
      • fine

        public void fine​(java.lang.String res,
                         java.lang.Object param)
        Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
      • fine

        public void fine​(java.lang.String res,
                         java.lang.Object param1,
                         java.lang.Object param2)
        Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.
        Parameters:
        res - the resource used for the message
        param1 - a parameter for the message
        param2 - a parameter for the message
      • fine

        public void fine​(java.lang.String res,
                         java.lang.Object[] params)
        Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.
        Parameters:
        res - the resource used for the message
        params - an array with parameters for the message
      • debug

        public void debug​(java.lang.String res)
        Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource given.
        Parameters:
        res - the resource used for the message
      • debug

        public void debug​(java.lang.String res,
                          java.lang.Object param)
        Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
      • debug

        public void debug​(java.lang.String res,
                          java.lang.Object param1,
                          java.lang.Object param2)
        Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.
        Parameters:
        res - the resource used for the message
        param1 - a parameter for the message
        param2 - a parameter for the message
      • debug

        public void debug​(java.lang.String res,
                          java.lang.Object[] params)
        Log a message with debug level if the debug mode flag is true, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.
        Parameters:
        res - the resource used for the message
        params - an array with parameters for the message
      • info

        public void info​(java.lang.String res)
        Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource.
        Parameters:
        res - the resource used for the message
      • info

        public void info​(java.lang.String res,
                         java.lang.Object param)
        Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
      • info

        public void info​(java.lang.String res,
                         java.lang.Object param1,
                         java.lang.Object param2)
        Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.
        Parameters:
        res - the resource used for the message
        param1 - a parameter for the message
        param2 - a parameter for the message
      • info

        public void info​(java.lang.String res,
                         java.lang.Object[] params)
        Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.
        Parameters:
        res - the resource used for the message
        params - an array with parameters for the message
      • warn

        public void warn​(java.lang.String res)
        Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource.
        Parameters:
        res - the resource used for the message
      • warn

        public void warn​(java.lang.String res,
                         java.lang.Object param)
        Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
      • warn

        public void warn​(java.lang.String res,
                         java.lang.Object param1,
                         java.lang.Object param2)
        Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.
        Parameters:
        res - the resource used for the message
        param1 - a parameter for the message
        param2 - a parameter for the message
      • warn

        public void warn​(java.lang.String res,
                         java.lang.Object[] params)
        Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.
        Parameters:
        res - the resource used for the message
        params - an array with parameters for the message
      • error

        public void error​(java.lang.String res)
        Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource.
        Parameters:
        res - the resource used for the message
      • error

        public void error​(java.lang.String res,
                          java.lang.Throwable error)
        Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a Throwable object.
        Parameters:
        res - the resource used for the message
        error - the Throwable to be logged
      • error

        public void error​(java.lang.String res,
                          java.lang.String param)
        Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
      • error

        public void error​(java.lang.String res,
                          java.lang.Object param,
                          java.lang.Throwable error)
        Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter and a Throwable object.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
        error - the Throwable to be logged
      • error

        public void error​(java.lang.String res,
                          java.lang.String param1,
                          java.lang.String param2)
        Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.
        Parameters:
        res - the resource used for the message
        param1 - a parameter for the message
        param2 - a parameter for the message
      • error

        public void error​(java.lang.String res,
                          java.lang.Object[] params)
        Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.
        Parameters:
        res - the resource used for the message
        params - an array with parameters for the message
      • error

        public void error​(java.lang.String res,
                          java.lang.Object[] params,
                          java.lang.Throwable error)
        Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters and a Throwable object.
        Parameters:
        res - the resource used for the message
        params - an array with parameters for the message
        error - the Throwable to be logged
      • fatal

        public void fatal​(java.lang.String res)
        Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource given.
        Parameters:
        res - the resource used for the message
      • fatal

        public void fatal​(java.lang.String res,
                          java.lang.Throwable err)
        Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a Throwable object.
        Parameters:
        res - the resource used for the message
        err - the Throwable to be logged
      • fatal

        public void fatal​(java.lang.String res,
                          java.lang.Object param)
        Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
      • fatal

        public void fatal​(java.lang.String res,
                          java.lang.Object param,
                          java.lang.Throwable err)
        Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter and a Throwable object.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
        err - the Throwable to be logged
      • fatal

        public void fatal​(java.lang.String res,
                          java.lang.Object[] params)
        Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes the given parameters.
        Parameters:
        res - the resource used for the message
        params - parameters for the message
      • log

        public void log​(java.lang.String level,
                        java.lang.String msg)
        Log a message with the specified level. This is done for all used loggers.
        Parameters:
        level - The level to use when logging
        msg - The string to be logged
      • exception

        public void exception​(java.lang.String res)
                       throws java.lang.Exception
        Throws a new exception with a custom message. The message is a NLS string formed using the given resource.
        Parameters:
        res - the resource used for the message
        Throws:
        java.lang.Exception - the thrown exception
      • exception

        public void exception​(java.lang.String res,
                              java.lang.Object param)
                       throws java.lang.Exception
        Throws a new exception with a custom message. The message is a NLS string formed using the given resource and an additional parameter.
        Parameters:
        res - the resource used for the message
        param - a parameter for the message
        Throws:
        java.lang.Exception - the thrown exception
      • exception

        public void exception​(java.lang.String res,
                              java.lang.Object param1,
                              java.lang.Object param2)
                       throws java.lang.Exception
        Throws a new exception with a custom message. The message is a NLS string formed using the given resource and two additional parameters.
        Parameters:
        res - the resource used for the message
        param1 - a parameter for the message
        param2 - a parameter for the message
        Throws:
        java.lang.Exception - the thrown exception
      • exception

        public void exception​(java.lang.String res,
                              java.lang.Object[] params)
                       throws java.lang.Exception
        Throws a new exception with a custom message. The message is a NLS string formed using the given resource and an array of additional parameters.
        Parameters:
        res - the resource used for the message
        params - parameters for the message
        Throws:
        java.lang.Exception - the thrown exception
      • dumpEntry

        public void dumpEntry​(Entry e)
        Dumps a formatted message to the logfile from the contents of an Entry
        Parameters:
        e - The entry to dump
        See Also:
        dump(java.lang.Object)
      • dump

        public void dump​(java.lang.Object o)
        This methods dumps an Object to the log file.
        Parameters:
        o - The entry to dump
        See Also:
        dumpEntry(com.ibm.di.entry.Entry)