Class AbstractSocketAppender<E>

All Implemented Interfaces:
Appender<E>, SocketConnector.ExceptionHandler, ContextAware, FilterAttachable<E>, LifeCycle
Direct Known Subclasses:
AbstractSSLSocketAppender, SocketAppender, SocketAppender

public abstract class AbstractSocketAppender<E> extends AppenderBase<E> implements SocketConnector.ExceptionHandler
An abstract base for module specific SocketAppender implementations in other logback modules.
Author:
Ceki Gülcü, Sébastien Pennec, Carl Harris, Sebastian Gröbler
  • Field Details

  • Constructor Details

  • Method Details

    • start

      public void start()
      Specified by:
      start in interface LifeCycle
      Overrides:
      start in class AppenderBase<E>
    • stop

      public void stop()
      Specified by:
      stop in interface LifeCycle
      Overrides:
      stop in class AppenderBase<E>
    • append

      protected void append(E event)
      Specified by:
      append in class AppenderBase<E>
    • connectionFailed

      public void connectionFailed(SocketConnector connector, Exception ex)
      Specified by:
      connectionFailed in interface SocketConnector.ExceptionHandler
    • newConnector

      protected SocketConnector newConnector(InetAddress address, int port, long initialDelay, long retryDelay)
      Creates a new SocketConnector.

      The default implementation creates an instance of DefaultSocketConnector. A subclass may override to provide a different SocketConnector implementation.

      Parameters:
      address - target remote address
      port - target remote port
      initialDelay - delay before the first connection attempt
      retryDelay - delay before a reconnection attempt
      Returns:
      socket connector
    • getSocketFactory

      Gets the default SocketFactory for the platform.

      Subclasses may override to provide a custom socket factory.

    • postProcessEvent

      protected abstract void postProcessEvent(E event)
      Post-processes an event before it is serialized for delivery to the remote receiver.
      Parameters:
      event - the event to post-process
    • getPST

      protected abstract PreSerializationTransformer<E> getPST()
      Get the pre-serialization transformer that will be used to transform each event into a Serializable object before delivery to the remote receiver.
      Returns:
      transformer object
    • setRemoteHost

      public void setRemoteHost(String host)
      The RemoteHost property takes the name of of the host where a corresponding server is running.
    • getRemoteHost

      Returns value of the RemoteHost property.
    • setPort

      public void setPort(int port)
      The Port property takes a positive integer representing the port where the server is waiting for connections.
    • getPort

      public int getPort()
      Returns value of the Port property.
    • setReconnectionDelay

      public void setReconnectionDelay(Duration delay)
      The reconnectionDelay property takes a positive Duration value representing the time to wait between each failed connection attempt to the server. The default value of this option is to 30 seconds.

      Setting this option to zero turns off reconnection capability.

    • getReconnectionDelay

      Returns value of the reconnectionDelay property.
    • setQueueSize

      public void setQueueSize(int queueSize)
      The queueSize property takes a non-negative integer representing the number of logging events to retain for delivery to the remote receiver. When the deque size is zero, event delivery to the remote receiver is synchronous. When the deque size is greater than zero, the append(Object) method returns immediately after enqueing the event, assuming that there is space available in the deque. Using a non-zero deque length can improve performance by eliminating delays caused by transient network delays.
      Parameters:
      queueSize - the deque size to set.
    • getQueueSize

      public int getQueueSize()
      Returns the value of the queueSize property.
    • setEventDelayLimit

      public void setEventDelayLimit(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

      Returns the value of the eventDelayLimit property.