Class RequestContextExportingAppender

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

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

Read 'Logging contextual information' for more information.

  • Field Summary

    Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase

    name, started

    Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

    context
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> newAppender)
     
    void
    addAttribute(String alias, io.netty.util.AttributeKey<?> attrKey)
    Adds the specified AttributeKey to the export list.
    void
    addAttribute(String alias, io.netty.util.AttributeKey<?> attrKey, Function<?,String> stringifier)
    Adds the specified AttributeKey to the export list.
    void
    Adds the specified BuiltInProperty to the export list.
    void
    Adds the specified HTTP request header name to the export list.
    void
    Adds the specified HTTP response header name to the export list.
    protected void
    append(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
     
    void
     
    boolean
    detachAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
     
    boolean
     
    ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>
     
    boolean
    isAttached(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
     
    Iterator<ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>>
     
    void
    setExport(String mdcKey)
    Adds the property represented by the specified MDC key to the export list.
    void
    setExportGroup(ExportGroupConfig exportGroupConfiguration)
    Adds the export group.
    void
    setExports(String mdcKeys)
    Adds the properties represented by the specified comma-separated MDC keys to the export list.
    void
    setPrefix(String prefix)
    Specifies a prefix of the default export group.
    void
     
    void
     

    Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase

    addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toString

    Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

    addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ch.qos.logback.core.spi.ContextAware

    addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
  • Constructor Details

    • RequestContextExportingAppender

      public RequestContextExportingAppender()
  • Method Details

    • addBuiltIn

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

      public void addAttribute(String alias, io.netty.util.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, io.netty.util.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.
    • setPrefix

      public void setPrefix(String prefix)
      Specifies a prefix of the default export group. Note: this method is meant to be used for XML configuration.
    • 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.
    • setExportGroup

      public void setExportGroup(ExportGroupConfig exportGroupConfiguration)
      Adds the export group. Note: this method is meant to be used for XML configuration.
    • append

      protected void append(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
      Specified by:
      append in class ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.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<ch.qos.logback.classic.spi.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<ch.qos.logback.classic.spi.ILoggingEvent>
    • addAppender

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

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

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

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

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

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

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