Class RequestContextExportingAppender

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<ILoggingEvent>
com.linecorp.armeria.common.logback.RequestContextExportingAppender
All Implemented Interfaces:
ch.qos.logback.core.Appender<ILoggingEvent>, ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<ILoggingEvent>, ch.qos.logback.core.spi.LifeCycle

public final class RequestContextExportingAppender
extends ch.qos.logback.core.UnsynchronizedAppenderBase<ILoggingEvent>
implements ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>
A Logback Appender that exports the properties of the current RequestContext to MDC.

Read 'Logging contextual information' for more information.

  • Constructor Details

  • Method Details

    • addBuiltIn

      public void addBuiltIn​(BuiltInProperty property)
      Adds the specified BuiltInProperty to the export list.
    • addAttribute

      public void addAttribute​(String alias, AttributeKey<?> attrKey)
      Adds the specified AttributeKey to the export list.
      Parameters:
      alias - the alias of the attribute to export
      attrKey - the key of the attribute to export
    • addAttribute

      public void addAttribute​(String alias, AttributeKey<?> attrKey, Function<?,​String> stringifier)
      Adds the specified AttributeKey to the export list.
      Parameters:
      alias - the alias of the attribute to export
      attrKey - the key of the attribute to export
      stringifier - the Function that converts the attribute value into a String
    • addRequestHeader

      public void addRequestHeader​(CharSequence name)
      Adds the specified HTTP request header name to the export list.
    • addResponseHeader

      public void addResponseHeader​(CharSequence name)
      Adds the specified HTTP response header name to the export list.
    • setExport

      public void setExport​(String mdcKey)
      Adds the property represented by the specified MDC key to the export list. Note: this method is meant to be used for XML configuration. Use add*() methods instead.
    • setExports

      public void setExports​(String mdcKeys)
      Adds the properties represented by the specified comma-separated MDC keys to the export list. Note: this method is meant to be used for XML configuration. Use add*() methods instead.
    • append

      protected void append​(ILoggingEvent eventObject)
      Specified by:
      append in class ch.qos.logback.core.UnsynchronizedAppenderBase<ILoggingEvent>
    • start

      public void start()
      Specified by:
      start in interface ch.qos.logback.core.spi.LifeCycle
      Overrides:
      start in class ch.qos.logback.core.UnsynchronizedAppenderBase<ILoggingEvent>
    • stop

      public void stop()
      Specified by:
      stop in interface ch.qos.logback.core.spi.LifeCycle
      Overrides:
      stop in class ch.qos.logback.core.UnsynchronizedAppenderBase<ILoggingEvent>
    • addAppender

      public void addAppender​(ch.qos.logback.core.Appender<ILoggingEvent> newAppender)
      Specified by:
      addAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>
    • iteratorForAppenders

      public Iterator<ch.qos.logback.core.Appender<ILoggingEvent>> iteratorForAppenders()
      Specified by:
      iteratorForAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>
    • getAppender

      public ch.qos.logback.core.Appender<ILoggingEvent> getAppender​(String name)
      Specified by:
      getAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>
    • isAttached

      public boolean isAttached​(ch.qos.logback.core.Appender<ILoggingEvent> appender)
      Specified by:
      isAttached in interface ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>
    • detachAndStopAllAppenders

      public void detachAndStopAllAppenders()
      Specified by:
      detachAndStopAllAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>
    • detachAppender

      public boolean detachAppender​(ch.qos.logback.core.Appender<ILoggingEvent> appender)
      Specified by:
      detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>
    • detachAppender

      public boolean detachAppender​(String name)
      Specified by:
      detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ILoggingEvent>