Class TcpAppender

  • All Implemented Interfaces:
    ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.net.SocketConnector.ExceptionHandler, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.LifeCycle, Runnable

    public class TcpAppender
    extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    implements Runnable, ch.qos.logback.core.net.SocketConnector.ExceptionHandler
    Logback Appender which writes its events to a TCP port. This class is based on the logic of Logback's SocketAppender, but does not try to serialize Java objects for deserialization and logging elsewhere.
    • Field Summary

      • Fields inherited from class ch.qos.logback.core.AppenderBase

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

        context
    • Constructor Summary

      Constructors 
      Constructor Description
      TcpAppender()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void append​(ch.qos.logback.classic.spi.ILoggingEvent event)  
      void connectionFailed​(ch.qos.logback.core.net.SocketConnector socketConnector, Exception e)  
      ch.qos.logback.core.util.Duration getEventDelayLimit()
      Returns the value of the eventDelayLimit property.
      ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> getLayout()  
      int getPort()  
      int getQueueSize()  
      int getReconnectionDelay()  
      String getRemoteHost()  
      void run()  
      void setEventDelayLimit​(ch.qos.logback.core.util.Duration eventDelayLimit)
      The eventDelayLimit takes a non-negative integer representing the number of milliseconds to allow the appender to block if the underlying BlockingQueue is full.
      void setLayout​(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout)  
      void setPort​(int port)  
      void setQueueSize​(int queueSize)  
      void setReconnectionDelay​(int reconnectionDelay)  
      void setRemoteHost​(String host)  
      void start()  
      void stop()  
      • Methods inherited from class ch.qos.logback.core.AppenderBase

        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 interface ch.qos.logback.core.spi.ContextAware

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

      • TcpAppender

        public TcpAppender()
    • Method Detail

      • connectionFailed

        public void connectionFailed​(ch.qos.logback.core.net.SocketConnector socketConnector,
                                     Exception e)
        Specified by:
        connectionFailed in interface ch.qos.logback.core.net.SocketConnector.ExceptionHandler
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • start

        public void start()
        Specified by:
        start in interface ch.qos.logback.core.spi.LifeCycle
        Overrides:
        start in class ch.qos.logback.core.AppenderBase<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.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
      • append

        protected void append​(ch.qos.logback.classic.spi.ILoggingEvent event)
        Specified by:
        append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
      • setRemoteHost

        public void setRemoteHost​(String host)
      • getRemoteHost

        public String getRemoteHost()
      • setPort

        public void setPort​(int port)
      • getPort

        public int getPort()
      • setReconnectionDelay

        public void setReconnectionDelay​(int reconnectionDelay)
      • getReconnectionDelay

        public int getReconnectionDelay()
      • setQueueSize

        public void setQueueSize​(int queueSize)
      • getQueueSize

        public int getQueueSize()
      • setLayout

        public void setLayout​(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout)
      • getLayout

        public ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> getLayout()
      • setEventDelayLimit

        public void setEventDelayLimit​(ch.qos.logback.core.util.Duration eventDelayLimit)
        The eventDelayLimit takes a non-negative integer representing the number of milliseconds to allow the appender to block if the underlying BlockingQueue is full. Once this limit is reached, the event is dropped.
        Parameters:
        eventDelayLimit - the event delay limit
      • getEventDelayLimit

        public ch.qos.logback.core.util.Duration getEventDelayLimit()
        Returns the value of the eventDelayLimit property.