java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.AppenderBase<E>
ch.qos.logback.core.net.AbstractSocketAppender<E>
- All Implemented Interfaces:
Appender<E>
,SocketConnector.ExceptionHandler
,ContextAware
,FilterAttachable<E>
,LifeCycle
- Direct Known Subclasses:
AbstractSSLSocketAppender
,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 Summary
Modifier and TypeFieldDescriptionstatic final int
The default port number of remote logging server (4560).static final int
Default size of the deque used to hold logging events that are destined for the remote peer.static final int
The default reconnection delay (30000 milliseconds or 30 seconds).Fields inherited from class ch.qos.logback.core.AppenderBase
name, started
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
connectionFailed
(SocketConnector connector, Exception ex) Returns the value of the eventDelayLimit property.int
getPort()
Returns value of the Port property.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.int
Returns the value of the queueSize property.Returns value of the reconnectionDelay property.Returns value of the RemoteHost property.protected SocketFactory
Gets the defaultSocketFactory
for the platform.protected SocketConnector
newConnector
(InetAddress address, int port, long initialDelay, long retryDelay) Creates a newSocketConnector
.protected abstract void
postProcessEvent
(E event) Post-processes an event before it is serialized for delivery to the remote receiver.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.void
setPort
(int port) The Port property takes a positive integer representing the port where the server is waiting for connections.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.void
setReconnectionDelay
(Duration delay) The reconnectionDelay property takes a positiveDuration
value representing the time to wait between each failed connection attempt to the server.void
setRemoteHost
(String host) The RemoteHost property takes the name of the host where a corresponding server is running.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 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
-
Field Details
-
DEFAULT_PORT
The default port number of remote logging server (4560).- See Also:
-
DEFAULT_RECONNECTION_DELAY
The default reconnection delay (30000 milliseconds or 30 seconds).- See Also:
-
DEFAULT_QUEUE_SIZE
Default size of the deque used to hold logging events that are destined for the remote peer.- See Also:
-
-
Constructor Details
-
AbstractSocketAppender
protected AbstractSocketAppender()Constructs a new appender.
-
-
Method Details
-
start
-
stop
-
append
- Specified by:
append
in classAppenderBase<E>
-
connectionFailed
- Specified by:
connectionFailed
in interfaceSocketConnector.ExceptionHandler
-
newConnector
protected SocketConnector newConnector(InetAddress address, int port, long initialDelay, long retryDelay) Creates a newSocketConnector
.The default implementation creates an instance of
DefaultSocketConnector
. A subclass may override to provide a differentSocketConnector
implementation.- Parameters:
address
- target remote addressport
- target remote portinitialDelay
- delay before the first connection attemptretryDelay
- delay before a reconnection attempt- Returns:
- socket connector
-
getSocketFactory
Gets the defaultSocketFactory
for the platform.Subclasses may override to provide a custom socket factory.
-
postProcessEvent
Post-processes an event before it is serialized for delivery to the remote receiver.- Parameters:
event
- the event to post-process
-
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
The RemoteHost property takes the name of the host where a corresponding server is running. -
getRemoteHost
Returns value of the RemoteHost property. -
setPort
The Port property takes a positive integer representing the port where the server is waiting for connections. -
getPort
Returns value of the Port property. -
setReconnectionDelay
The reconnectionDelay property takes a positiveDuration
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
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, theappend(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
Returns the value of the queueSize property. -
setEventDelayLimit
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.
-