Interface Logger

All Known Subinterfaces:
FormatterLogger

@ProviderType public interface Logger
Provides methods for bundles to write messages to the log using SLF4J-style format strings.

Messages can be formatted by the Logger once the Logger determines the log level is enabled. Use a left curly bracket ('{' \u007B) followed by a right curly bracket ('}' \u007D) as a place holder for an argument: "{}". If you need to use the literal "{}" in the formatted message, precede the place holder with a reverse solidus ('\' \u005C): "\{}". If you need to place a backslash before the place holder, precede the reverse solidus with a reverse solidus: "\\{}".

You can also add a Throwable and/or ServiceReference to the generated LogEntry by passing them to the logging methods as additional arguments. If the last argument is a Throwable or a ServiceReference, it is added to the generated LogEntry and then, if the next to last argument is a ServiceReference or Throwable and not the same type as the last argument, it is also added to the generated LogEntry. These arguments will not be used as message arguments. For example:

 logger.info("Found service {}.", serviceReference, serviceReference);
 logger.warn("Something named {} happened.", name, serviceReference,
                throwable);
 logger.error("Failed.", exception);
 
Since:
1.4
  • Field Details

  • Method Details

    • getName

      String getName()
      Return the name of this Logger.
      Returns:
      The name of this Logger.
    • isTraceEnabled

      boolean isTraceEnabled()
      Is logging enabled for the LogLevel.TRACE level?
      Returns:
      true if logging is enabled for the LogLevel.TRACE level.
    • trace

      void trace(String message)
      Log a message at the LogLevel.TRACE level.
      Parameters:
      message - The message to log.
    • trace

      void trace(String format, Object arg)
      Log a formatted message at the LogLevel.TRACE level.
      Parameters:
      format - The format of the message to log.
      arg - The argument to format into the message.
    • trace

      void trace(String format, Object arg1, Object arg2)
      Log a formatted message at the LogLevel.TRACE level.
      Parameters:
      format - The format of the message to log.
      arg1 - The first argument to format into the message.
      arg2 - The second argument to format into the message.
    • trace

      void trace(String format, Object... arguments)
      Log a formatted message at the LogLevel.TRACE level.
      Parameters:
      format - The format of the message to log.
      arguments - The arguments to format into the message.
    • trace

      <E extends Exception> void trace(LoggerConsumer<E> consumer) throws E
      Perform the specified operation if logging enabled for the LogLevel.TRACE level.
      Parameters:
      consumer - The operation to perform on this Logger.
      Throws:
      E - An exception thrown by the operation.
    • isDebugEnabled

      boolean isDebugEnabled()
      Is logging enabled for the LogLevel.DEBUG level?
      Returns:
      true if logging is enabled for the LogLevel.DEBUG level.
    • debug

      void debug(String message)
      Log a message at the LogLevel.DEBUG level.
      Parameters:
      message - The message to log.
    • debug

      void debug(String format, Object arg)
      Log a formatted message at the LogLevel.DEBUG level.
      Parameters:
      format - The format of the message to log.
      arg - The argument to format into the message.
    • debug

      void debug(String format, Object arg1, Object arg2)
      Log a formatted message at the LogLevel.DEBUG level.
      Parameters:
      format - The format of the message to log.
      arg1 - The first argument to format into the message.
      arg2 - The second argument to format into the message.
    • debug

      void debug(String format, Object... arguments)
      Log a formatted message at the LogLevel.DEBUG level.
      Parameters:
      format - The format of the message to log.
      arguments - The arguments to format into the message.
    • debug

      <E extends Exception> void debug(LoggerConsumer<E> consumer) throws E
      Perform the specified operation if logging enabled for the LogLevel.DEBUG level.
      Parameters:
      consumer - The operation to perform on this Logger.
      Throws:
      E - An exception thrown by the operation.
    • isInfoEnabled

      boolean isInfoEnabled()
      Is logging enabled for the LogLevel.INFO level?
      Returns:
      true if logging is enabled for the LogLevel.INFO level.
    • info

      void info(String message)
      Log a message at the LogLevel.INFO level.
      Parameters:
      message - The message to log.
    • info

      void info(String format, Object arg)
      Log a formatted message at the LogLevel.INFO level.
      Parameters:
      format - The format of the message to log.
      arg - The argument to format into the message.
    • info

      void info(String format, Object arg1, Object arg2)
      Log a formatted message at the LogLevel.INFO level.
      Parameters:
      format - The format of the message to log.
      arg1 - The first argument to format into the message.
      arg2 - The second argument to format into the message.
    • info

      void info(String format, Object... arguments)
      Log a formatted message at the LogLevel.INFO level.
      Parameters:
      format - The format of the message to log.
      arguments - The arguments to format into the message.
    • info

      <E extends Exception> void info(LoggerConsumer<E> consumer) throws E
      Perform the specified operation if logging enabled for the LogLevel.INFO level.
      Parameters:
      consumer - The operation to perform on this Logger.
      Throws:
      E - An exception thrown by the operation.
    • isWarnEnabled

      boolean isWarnEnabled()
      Is logging enabled for the LogLevel.WARN level?
      Returns:
      true if logging is enabled for the LogLevel.WARN level.
    • warn

      void warn(String message)
      Log a message at the LogLevel.WARN level.
      Parameters:
      message - The message to log.
    • warn

      void warn(String format, Object arg)
      Log a formatted message at the LogLevel.WARN level.
      Parameters:
      format - The format of the message to log.
      arg - The argument to format into the message.
    • warn

      void warn(String format, Object arg1, Object arg2)
      Log a formatted message at the LogLevel.WARN level.
      Parameters:
      format - The format of the message to log.
      arg1 - The first argument to format into the message.
      arg2 - The second argument to format into the message.
    • warn

      void warn(String format, Object... arguments)
      Log a formatted message at the LogLevel.WARN level.
      Parameters:
      format - The format of the message to log.
      arguments - The arguments to format into the message.
    • warn

      <E extends Exception> void warn(LoggerConsumer<E> consumer) throws E
      Perform the specified operation if logging enabled for the LogLevel.WARN level.
      Parameters:
      consumer - The operation to perform on this Logger.
      Throws:
      E - An exception thrown by the operation.
    • isErrorEnabled

      boolean isErrorEnabled()
      Is logging enabled for the LogLevel.ERROR level?
      Returns:
      true if logging is enabled for the LogLevel.ERROR level.
    • error

      void error(String message)
      Log a message at the LogLevel.ERROR level.
      Parameters:
      message - The message to log.
    • error

      void error(String format, Object arg)
      Log a formatted message at the LogLevel.ERROR level.
      Parameters:
      format - The format of the message to log.
      arg - The argument to format into the message.
    • error

      void error(String format, Object arg1, Object arg2)
      Log a formatted message at the LogLevel.ERROR level.
      Parameters:
      format - The format of the message to log.
      arg1 - The first argument to format into the message.
      arg2 - The second argument to format into the message.
    • error

      void error(String format, Object... arguments)
      Log a formatted message at the LogLevel.ERROR level.
      Parameters:
      format - The format of the message to log.
      arguments - The arguments to format into the message.
    • error

      <E extends Exception> void error(LoggerConsumer<E> consumer) throws E
      Perform the specified operation if logging enabled for the LogLevel.ERROR level.
      Parameters:
      consumer - The operation to perform on this Logger.
      Throws:
      E - An exception thrown by the operation.
    • audit

      void audit(String message)
      Log a message at the LogLevel.AUDIT level.
      Parameters:
      message - The message to log.
    • audit

      void audit(String format, Object arg)
      Log a formatted message at the LogLevel.AUDIT level.
      Parameters:
      format - The format of the message to log.
      arg - The argument to format into the message.
    • audit

      void audit(String format, Object arg1, Object arg2)
      Log a formatted message at the LogLevel.AUDIT level.
      Parameters:
      format - The format of the message to log.
      arg1 - The first argument to format into the message.
      arg2 - The second argument to format into the message.
    • audit

      void audit(String format, Object... arguments)
      Log a formatted message at the LogLevel.AUDIT level.
      Parameters:
      format - The format of the message to log.
      arguments - The arguments to format into the message.