Class KafkaLogbackAppender<E>

  • Type Parameters:
    E - The log object
    All Implemented Interfaces:
    ch.qos.logback.core.Appender<E>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<E>, ch.qos.logback.core.spi.LifeCycle

    public class KafkaLogbackAppender<E>
    extends ch.qos.logback.core.spi.ContextAwareBase
    implements ch.qos.logback.core.Appender<E>
    This is a logback implementation that writes all logs to a kafka queue. Kafka may prove a nice way to capture logs from disparate boxes and processes onto a single bus.
    • Field Summary

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

        context
    • Constructor Summary

      Constructors 
      Constructor Description
      KafkaLogbackAppender​(java.util.Properties producerConfig, java.lang.String topic)  
    • Method Summary

      Modifier and Type Method Description
      void addFilter​(ch.qos.logback.core.filter.Filter<E> filter)  
      void clearAllFilters()  
      void doAppend​(E e)  
      java.util.List<ch.qos.logback.core.filter.Filter<E>> getCopyOfAttachedFiltersList()  
      ch.qos.logback.core.spi.FilterReply getFilterChainDecision​(E e)  
      java.lang.String getName()  
      java.util.Properties getProducerConfig()  
      java.lang.String getTopic()  
      boolean isStarted()  
      void setName​(java.lang.String s)  
      void start()  
      void stop()  
      • 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, toString, wait, wait, wait
      • Methods inherited from interface ch.qos.logback.core.spi.ContextAware

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

      • KafkaLogbackAppender

        public KafkaLogbackAppender​(java.util.Properties producerConfig,
                                    java.lang.String topic)
    • Method Detail

      • getProducerConfig

        public java.util.Properties getProducerConfig()
      • getTopic

        public java.lang.String getTopic()
      • start

        public void start()
        Specified by:
        start in interface ch.qos.logback.core.spi.LifeCycle
      • stop

        public void stop()
        Specified by:
        stop in interface ch.qos.logback.core.spi.LifeCycle
      • isStarted

        public boolean isStarted()
        Specified by:
        isStarted in interface ch.qos.logback.core.spi.LifeCycle
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface ch.qos.logback.core.Appender<E>
      • doAppend

        public void doAppend​(E e)
                      throws ch.qos.logback.core.LogbackException
        Specified by:
        doAppend in interface ch.qos.logback.core.Appender<E>
        Throws:
        ch.qos.logback.core.LogbackException
      • setName

        public void setName​(java.lang.String s)
        Specified by:
        setName in interface ch.qos.logback.core.Appender<E>
      • addFilter

        public void addFilter​(ch.qos.logback.core.filter.Filter<E> filter)
        Specified by:
        addFilter in interface ch.qos.logback.core.spi.FilterAttachable<E>
      • clearAllFilters

        public void clearAllFilters()
        Specified by:
        clearAllFilters in interface ch.qos.logback.core.spi.FilterAttachable<E>
      • getCopyOfAttachedFiltersList

        public java.util.List<ch.qos.logback.core.filter.Filter<E>> getCopyOfAttachedFiltersList()
        Specified by:
        getCopyOfAttachedFiltersList in interface ch.qos.logback.core.spi.FilterAttachable<E>
      • getFilterChainDecision

        public ch.qos.logback.core.spi.FilterReply getFilterChainDecision​(E e)
        Specified by:
        getFilterChainDecision in interface ch.qos.logback.core.spi.FilterAttachable<E>