Class ODataLogger

java.lang.Object
com.ptc.odata.core.ODataLogger

public class ODataLogger extends Object
ODataLogger is a wrapper around versions 1 and 2 of log4j. WRS needs to support both the old and new version of log4j, this class allows a single API.

Supported API: true

Extendable: false
  • Method Details

    • getLogger

      public static ODataLogger getLogger(String name)
      Retrieve a logger named according to the value of the name parameter. If the named logger already exists, then the existing instance will be returned. Otherwise, a new instance is created.

      By default, loggers do not have a set level but inherit it from their neareast ancestor with a set level. This is one of the central features of log4j.

      Supported API: true

      Parameters:
      name - The name of the logger to retrieve.
    • getLogger

      public static ODataLogger getLogger(Class<?> clazz)
      Shorthand for getLogger(clazz.getName()).

      Supported API: true
      Parameters:
      clazz - The name of clazz will be used as the name of the logger to retrieve. See getLogger(String) for more detailed information.
    • getLevel

      public final Object getLevel()
      Returns the assigned
      invalid reference
      Level
      , if any, for this Category.

      Supported API: true
      Returns:
      Level - the assigned Level, can be null.
    • error

      public void error(Object message, Throwable t)
      Log a message object with the ERROR level including the stack trace of the Throwable t passed as parameter.

      See error(Object) form for more detailed information.

      Supported API: true

      Parameters:
      message - the message object to log.
      t - the exception to log, including its stack trace.
    • error

      public void error(Object message)
      Log a message object with the
      invalid reference
      ERROR
      Level.

      This method first checks if this category is ERROR enabled by comparing the level of this category with

      invalid reference
      ERROR
      Level. If this category is ERROR enabled, then it converts the message object passed as parameter to a string. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

      WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the error(Object, Throwable) form instead.

      Supported API: true

      Parameters:
      message - the message object to log
    • isDebugEnabled

      public boolean isDebugEnabled()
      Check whether this category is enabled for the DEBUG Level.

      This function is intended to lessen the computational cost of disabled log debug statements.

      For some cat Category object, when you write,

       cat.debug("This is entry number: " + i);
       

      You incur the cost constructing the message, concatenatiion in this case, regardless of whether the message is logged or not.

      If you are worried about speed, then you should write

       if (cat.isDebugEnabled()) {
           cat.debug("This is entry number: " + i);
       }
       

      This way you will not incur the cost of parameter construction if debugging is disabled for cat. On the other hand, if the cat is debug enabled, you will incur the cost of evaluating whether the category is debug enabled twice. Once in isDebugEnabled and once in the debug. This is an insignificant overhead since evaluating a category takes about 1%% of the time it takes to actually log.

      Supported API: true

      Returns:
      boolean - true if this category is debug enabled, false otherwise.
    • debug

      public void debug(Object message)
      Log a message object with the
      invalid reference
      DEBUG
      level.

      This method first checks if this category is DEBUG enabled by comparing the level of this category with the

      invalid reference
      DEBUG
      level. If this category is DEBUG enabled, then it converts the message object (passed as parameter) to a string. It then proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

      WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the debug(Object, Throwable) form instead.

      Supported API: true

      Parameters:
      message - the message object to log.
    • trace

      public void trace(Supplier<String> message)
      Log trace messages.

      Supported API: true
      Parameters:
      message -
    • debug

      public void debug(Supplier<String> message)
      Log debug messages.

      Supported API: true
      Parameters:
      message -
    • debug

      public void debug(Supplier<String> message, Throwable t)
      Log debug messages.

      Supported API: true
      Parameters:
      message -
    • debug

      public void debug(Object message, Throwable t)
      Log a message object with the DEBUG level including the stack trace of the Throwable t passed as parameter.

      See debug(Object) form for more detailed information.

      Supported API: true

      Parameters:
      message - the message object to log.
      t - the exception to log, including its stack trace.
    • isInfoEnabled

      public boolean isInfoEnabled()
      Check whether this category is enabled for the info Level. See also isDebugEnabled().

      Supported API: true
      Returns:
      boolean - true if this category is enabled for level info, false otherwise.
    • info

      public void info(Object message)
      Log a message object with the
      invalid reference
      INFO
      Level.

      This method first checks if this category is INFO enabled by comparing the level of this category with

      invalid reference
      INFO
      Level. If the category is INFO enabled, then it converts the message object passed as parameter to a string. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

      WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the info(Object, Throwable) form instead.

      Supported API: true

      Parameters:
      message - the message object to log
    • info

      public void info(Object message, Throwable t)
      Log a message object with the INFO level including the stack trace of the Throwable t passed as parameter.

      See info(Object) for more detailed information.

      Supported API: true

      Parameters:
      message - the message object to log.
      t - the exception to log, including its stack trace.
    • isTraceEnabled

      public boolean isTraceEnabled()
      Check whether this category is enabled for the TRACE Level.

      Supported API: true
      Returns:
      boolean - true if this category is enabled for level TRACE, false otherwise.
    • trace

      public void trace(Object message)
      Log a message object with the TRACE level including the stack trace of the Throwablet passed as parameter.

      See debug(Object) form for more detailed information.



      Supported API: true
      Parameters:
      message - the message object to log.
      t - the exception to log, including its stack trace.
    • warn

      public void warn(Object message)
      Log a message object with the
      invalid reference
      WARN
      Level.

      This method first checks if this category is WARN enabled by comparing the level of this category with

      invalid reference
      WARN
      Level. If the category is WARN enabled, then it converts the message object passed as parameter to a string. It proceeds to call all the registered appenders in this category and also higher in the hieararchy depending on the value of the additivity flag.

      WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the warn(Object, Throwable) form instead.



      Supported API: true

      Parameters:
      message - the message object to log.
    • warn

      public void warn(Object message, Throwable t)
      Log a message with the WARN level including the stack trace of the Throwable t passed as parameter.

      See warn(Object) for more detailed information.

      Supported API: true

      Parameters:
      message - the message object to log.
      t - the exception to log, including its stack trace.
    • fatal

      public void fatal(Object message)
      Log a message object with the
      invalid reference
      FATAL
      Level.

      This method first checks if this category is FATAL enabled by comparing the level of this category with

      invalid reference
      FATAL
      Level. If the category is FATAL enabled, then it converts the message object passed as parameter to a string. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

      WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the fatal(Object, Throwable) form instead.

      Supported API: true

      Parameters:
      message - the message object to log
    • fatal

      public void fatal(Object message, Throwable t)
      Log a message object with the FATAL level including the stack trace of the Throwable t passed as parameter.

      See fatal(Object) for more detailed information.

      Supported API: true

      Parameters:
      message - the message object to log.
      t - the exception to log, including its stack trace.