Class SLF4JMappedDiagnosticContext

java.lang.Object
org.tentackle.log.AbstractMappedDiagnosticContext
org.tentackle.log.slf4j.SLF4JMappedDiagnosticContext
All Implemented Interfaces:
MappedDiagnosticContext

@Service(SLF4JMappedDiagnosticContext.class) public class SLF4JMappedDiagnosticContext extends AbstractMappedDiagnosticContext
The SLF4J mdc implementation.
Author:
harald
  • Constructor Details

    • SLF4JMappedDiagnosticContext

      public SLF4JMappedDiagnosticContext()
      Creates the MDC for SLF4J.
  • Method Details

    • getInstance

      public static SLF4JMappedDiagnosticContext getInstance()
      The singleton.
      Returns:
      the singleton
    • put

      public void put(String key, String val)
      Description copied from interface: MappedDiagnosticContext
      Put a context value (the val parameter) as identified with the key parameter into the current thread's context map. The key parameter cannot be null. The val parameter can be null only if the underlying implementation supports it.

      This method delegates all work to the MDC of the underlying logging system.

      Throws IllegalArgumentException in case the "key" parameter is null.

      Parameters:
      key - the key
      val - the value
    • get

      public String get(String key)
      Description copied from interface: MappedDiagnosticContext
      Get the context identified by the key parameter. The key parameter cannot be null.

      This method delegates all work to the MDC of the underlying logging system.

      Throws IllegalArgumentException in case the "key" parameter is null.

      Parameters:
      key - the key
      Returns:
      the string value identified by the key parameter.
    • remove

      public void remove(String key)
      Description copied from interface: MappedDiagnosticContext
      Removes the context identified by the key parameter using the underlying system's MDC implementation. The key parameter cannot be null. This method does nothing if there is no previous value associated with key.

      Throws IllegalArgumentException in case the "key" parameter is null.

      Parameters:
      key - the key
    • clear

      public void clear()
      Description copied from interface: MappedDiagnosticContext
      Clear all entries in the MDC of the underlying implementation.
    • getContext

      public Map<String,String> getContext()
      Description copied from class: AbstractMappedDiagnosticContext
      Gets the map.

      Note: may be a copy of the internal map, i.e. modifications may not show up in the real MDC.

      Specified by:
      getContext in class AbstractMappedDiagnosticContext
      Returns:
      the key/value map, never null