Interface LoggerProvider

All Known Implementing Classes:
JBossLogManagerProvider, JDKLoggerProvider, Log4j2LoggerProvider, Log4jLoggerProvider, Slf4jLoggerProvider

public interface LoggerProvider
A contract for the log provider implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all entries from the message diagnostics context.
    void
    Clears the nested diagnostics context.
    Returns a logger which is backed by a logger from the log provider.
    Returns the value for the key on the message diagnostics context or null if no value was found.
    Returns the map from the context.
    Retrieves the current values set for the nested diagnostics context.
    int
    The current depth of the nested diagnostics context.
    Peeks at the top value from the stack and returns it.
    Pops top value from the stack and returns it.
    void
    pushNdc(String message)
    Pushes a value to the nested diagnostics context stack.
    putMdc(String key, Object value)
    Puts the value onto the message diagnostics context.
    void
    Removes the value from the message diagnostics context.
    void
    setNdcMaxDepth(int maxDepth)
    Sets maximum depth of the stack removing any entries below the maximum depth.
  • Method Details

    • getLogger

      Logger getLogger(String name)
      Returns a logger which is backed by a logger from the log provider.

      Note: this should never be null

      Parameters:
      name - the name of the logger
      Returns:
      a logger for the log provider logger.
    • clearMdc

      void clearMdc()
      Removes all entries from the message diagnostics context.
    • putMdc

      Object putMdc(String key, Object value)
      Puts the value onto the message diagnostics context.
      Parameters:
      key - the key for the value
      value - the value
      Returns:
      the previous value set or null if no value was set
    • getMdc

      Object getMdc(String key)
      Returns the value for the key on the message diagnostics context or null if no value was found.
      Parameters:
      key - the key to lookup the value for
      Returns:
      the value or null if not found
    • removeMdc

      void removeMdc(String key)
      Removes the value from the message diagnostics context.
      Parameters:
      key - the key of the value to remove
    • getMdcMap

      Map<String,Object> getMdcMap()
      Returns the map from the context.

      Note that in most implementations this is an expensive operation and should be used sparingly.

      Returns:
      the map from the context or an empty map if the context is null
    • clearNdc

      void clearNdc()
      Clears the nested diagnostics context.
    • getNdc

      String getNdc()
      Retrieves the current values set for the nested diagnostics context.
      Returns:
      the current value set or null if no value was set
    • getNdcDepth

      int getNdcDepth()
      The current depth of the nested diagnostics context.
      Returns:
      the current depth of the stack
    • popNdc

      String popNdc()
      Pops top value from the stack and returns it.
      Returns:
      the top value from the stack or an empty string if no value was set
    • peekNdc

      String peekNdc()
      Peeks at the top value from the stack and returns it.
      Returns:
      the value or an empty string
    • pushNdc

      void pushNdc(String message)
      Pushes a value to the nested diagnostics context stack.
      Parameters:
      message - the message to push
    • setNdcMaxDepth

      void setNdcMaxDepth(int maxDepth)
      Sets maximum depth of the stack removing any entries below the maximum depth.
      Parameters:
      maxDepth - the maximum depth to set