Class Log4jLogger_impl

java.lang.Object
org.apache.uima.util.impl.Log4jLogger_impl
All Implemented Interfaces:
Logger

public class Log4jLogger_impl extends Object implements Logger
UIMA Logging interface implementation for Log4j
  • Field Details

    • EXCEPTION_MESSAGE

      private static final String EXCEPTION_MESSAGE
      See Also:
    • logger

      private org.apache.log4j.Logger logger
      logger object from the underlying Log4j logging framework
    • mResourceManager

      private ResourceManager mResourceManager
      ResourceManager whose extension ClassLoader will be used to locate the message digests. Null will cause the ClassLoader to default to this.class.getClassLoader().
  • Constructor Details

    • Log4jLogger_impl

      private Log4jLogger_impl(Class<?> component)
      create a new LogWrapper class for the specified source class
      Parameters:
      component - specified source class
    • Log4jLogger_impl

      private Log4jLogger_impl()
      create a new LogWrapper object with the default logger from the Log4j logging framework
  • Method Details

    • getInstance

      public static Logger getInstance(Class<?> component)
      Creates a new Log4jLogger instance for the specified source class
      Parameters:
      component - current source class
      Returns:
      Logger returns the JSR47Logger object for the specified class
    • getInstance

      public static Logger getInstance()
      Creates a new Log4jLogger instance with the default Log4j framework logger
      Returns:
      Logger returns the JSR47Logger object with the default Log4j framework logger
    • log

      @Deprecated public void log(String aMessage)
      Deprecated.
      use new function with log level
      Logs a message with level INFO.
      Specified by:
      log in interface Logger
      Parameters:
      aMessage - the message to be logged
    • log

      @Deprecated public void log(String aResourceBundleName, String aMessageKey, Object[] aArguments)
      Deprecated.
      use new function with log level
      Logs a message with a message key and the level INFO
      Specified by:
      log in interface Logger
      Parameters:
      aResourceBundleName - base name of resource bundle
      aMessageKey - key of message to localize with message level INFO
      aArguments - arguments to message (may be null if none)
      See Also:
    • logException

      @Deprecated public void logException(Exception aException)
      Deprecated.
      use new function with log level
      Logs an exception with level INFO
      Specified by:
      logException in interface Logger
      Parameters:
      aException - the exception to be logged
    • setOutputStream

      @Deprecated public void setOutputStream(OutputStream out)
      Deprecated.
      use external configuration possibility
      Description copied from interface: Logger
      Sets the output stream to which log messages will go. Setting the output stream to null will disable the logger.
      Specified by:
      setOutputStream in interface Logger
      Parameters:
      out - OutputStream to which log messages will be printed
      See Also:
    • setOutputStream

      @Deprecated public void setOutputStream(PrintStream out)
      Deprecated.
      use external configuration possibility
      Description copied from interface: Logger
      Sets the output stream to which log messages will go. Setting the output stream to null will disable the logger.
      Specified by:
      setOutputStream in interface Logger
      Parameters:
      out - PrintStream to which log messages will be printed
      See Also:
    • isLoggable

      public boolean isLoggable(Level level)
      Description copied from interface: Logger
      Checks if the argument level is greater or equal to the specified level
      Specified by:
      isLoggable in interface Logger
      Parameters:
      level - message level
      Returns:
      boolean - true if the argument level is greater or equal to the specified level
    • setLevel

      public void setLevel(Level level)
      Description copied from interface: Logger
      Sets the level of messages that will be logged by this logger. Note that if you call UIMAFramework.getLogger().setLevel(level), this will only change the logging level for messages produced by the UIMA framework. It will NOT change the logging level for messages produced by annotators. To change the logging level for an annotator, use UIMAFramework.getLogger(YourAnnotatorClass.class).setLevel(level).

      If you need more flexibility it configuring the logger, consider using the standard Java logger properties file or the java.util.logging APIs.

      Specified by:
      setLevel in interface Logger
      Parameters:
      level - message level
    • log

      public void log(Level level, String aMessage)
      Description copied from interface: Logger
      Logs a message.
      Specified by:
      log in interface Logger
      Parameters:
      level - message level
      aMessage - the message to be logged
    • log

      public void log(Level level, String aMessage, Object param1)
      Description copied from interface: Logger
      Logs a message with one parameter
      Specified by:
      log in interface Logger
      Parameters:
      level - message level
      aMessage - the message to be logged
      param1 - message parameter
    • log

      public void log(Level level, String aMessage, Object[] params)
      Description copied from interface: Logger
      Logs a message with an arbitrary number of parameters
      Specified by:
      log in interface Logger
      Parameters:
      level - message level
      aMessage - the message to be logged
      params - message parameter array
    • log

      public void log(Level level, String aMessage, Throwable thrown)
      Description copied from interface: Logger
      Logs a message and a throwable object
      Specified by:
      log in interface Logger
      Parameters:
      level - message level
      aMessage - the message to be logged
      thrown - throwable object
    • logrb

      public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msgKey, Object param1)
      Description copied from interface: Logger
      Logs a message with a message key and one parameter. The real message is extracted from a resource bundle.
      Specified by:
      logrb in interface Logger
      Parameters:
      level - message level
      sourceClass - source class name
      sourceMethod - source method name
      bundleName - resource bundle
      msgKey - message key
      param1 - message parameter
    • logrb

      public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msgKey, Object[] params)
      Description copied from interface: Logger
      Logs a message with a message key and an arbitrary number of parameters. The real message is extracted from a resource bundle.
      Specified by:
      logrb in interface Logger
      Parameters:
      level - message level
      sourceClass - source class name
      sourceMethod - source method name
      bundleName - resource bundle
      msgKey - message key
      params - message parameter array with an arbitrary number of parameters
    • logrb

      public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msgKey, Throwable thrown)
      Description copied from interface: Logger
      Logs a message with a message key and a throwable object. The real message is extracted from a resource bundle.
      Specified by:
      logrb in interface Logger
      Parameters:
      level - message level
      sourceClass - source class name
      sourceMethod - source method name
      bundleName - resource bundle
      msgKey - message key
      thrown - throwable object
    • logrb

      public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msgKey)
      Description copied from interface: Logger
      Logs a message with a message key. The real message is extracted from a resource bundle.
      Specified by:
      logrb in interface Logger
      Parameters:
      level - message level
      sourceClass - source class name
      sourceMethod - source method name
      bundleName - resource bundle
      msgKey - message key
    • log

      public void log(String wrapperFQCN, Level level, String message, Throwable thrown)
      Description copied from interface: Logger
      Generic logging method intended for logging wrappers.
      Specified by:
      log in interface Logger
      Parameters:
      wrapperFQCN - fully qualified class name of the wrapper
      level - message level
      message - message
      thrown - throwable object
    • setResourceManager

      public void setResourceManager(ResourceManager resourceManager)
      Description copied from interface: Logger
      Sets the ResourceManager to use for message localization. This method is intended for use by the framework, not by user code.
      Specified by:
      setResourceManager in interface Logger
      Parameters:
      resourceManager - A resource manager instance whose extension ClassLoader (if any) will be used for message localization by this logger.
    • getExtensionClassLoader

      private ClassLoader getExtensionClassLoader()
      Gets the extension ClassLoader to used to locate the message digests. If this returns null, then message digests will be searched for using this.class.getClassLoader().
    • getLog4jLevel

      private org.apache.log4j.Level getLog4jLevel(Level level)
      log4j level mapping to UIMA level mapping. SEVERE (highest value) -> SEVERE WARNING -%gt; WARNING INFO -%gt; INFO CONFIG -%gt; CONFIG FINE -%gt; FINE FINER -> FINER FINEST (lowest value) -%gt; FINEST OFF -%gt; OFF ALL -%gt; ALL
      Parameters:
      level - uima level
      Returns:
      Level - corresponding JSR47 level
    • getStackTraceInfo

      private String[] getStackTraceInfo(Throwable thrown)
      returns the method name and the line number if available
      Parameters:
      thrown - the thrown
      Returns:
      String[] - fist element is the source class, second element is the method name with linenumber if available