Package ch.qos.logback.classic.net
Class SocketReceiver
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.classic.net.ReceiverBase
ch.qos.logback.classic.net.SocketReceiver
- All Implemented Interfaces:
SocketConnector.ExceptionHandler
,ContextAware
,LifeCycle
,Runnable
- Direct Known Subclasses:
SSLSocketReceiver
public class SocketReceiver
extends ReceiverBase
implements Runnable, SocketConnector.ExceptionHandler
A component that receives serialized
ILoggingEvent
objects from a
remote appender over a Socket
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private InetAddress
private static final int
private int
private String
private int
private String
private Socket
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactivateConnector
(SocketConnector connector) void
connectionFailed
(SocketConnector connector, Exception ex) private SocketConnector
createConnector
(InetAddress address, int port, int initialDelay, int retryDelay) private void
protected Runnable
Provides the runnable task this receiver will execute.protected SocketFactory
protected SocketConnector
newConnector
(InetAddress address, int port, int initialDelay, int retryDelay) protected void
onStop()
Allows a subclass to participate in receiver shutdown.void
run()
void
setAcceptConnectionTimeout
(int acceptConnectionTimeout) void
setPort
(int port) void
setReconnectionDelay
(int reconnectionDelay) void
setRemoteHost
(String remoteHost) protected boolean
Determines whether this receiver should start.private Socket
Methods inherited from class ch.qos.logback.classic.net.ReceiverBase
isStarted, start, stop
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Field Details
-
DEFAULT_ACCEPT_CONNECTION_DELAY
private static final int DEFAULT_ACCEPT_CONNECTION_DELAY- See Also:
-
remoteHost
-
address
-
port
private int port -
reconnectionDelay
private int reconnectionDelay -
acceptConnectionTimeout
private int acceptConnectionTimeout -
receiverId
-
socket
-
connectorTask
-
-
Constructor Details
-
SocketReceiver
public SocketReceiver()
-
-
Method Details
-
shouldStart
protected boolean shouldStart()Determines whether this receiver should start.Subclasses will implement this method to do any subclass-specific validation. The subclass's
ReceiverBase.getRunnableTask()
method will be invoked (and the task returned will be submitted to the executor) if and only if this method returnstrue
- Specified by:
shouldStart
in classReceiverBase
- Returns:
- flag indicating whether this receiver should start
-
onStop
protected void onStop()Allows a subclass to participate in receiver shutdown.- Specified by:
onStop
in classReceiverBase
-
getRunnableTask
Description copied from class:ReceiverBase
Provides the runnable task this receiver will execute.- Specified by:
getRunnableTask
in classReceiverBase
- Returns:
- runnable task
-
run
public void run() -
createConnector
private SocketConnector createConnector(InetAddress address, int port, int initialDelay, int retryDelay) -
activateConnector
-
waitForConnectorToReturnASocket
- Throws:
InterruptedException
-
dispatchEvents
-
connectionFailed
- Specified by:
connectionFailed
in interfaceSocketConnector.ExceptionHandler
-
newConnector
protected SocketConnector newConnector(InetAddress address, int port, int initialDelay, int retryDelay) -
getSocketFactory
-
setRemoteHost
-
setPort
public void setPort(int port) -
setReconnectionDelay
public void setReconnectionDelay(int reconnectionDelay) -
setAcceptConnectionTimeout
public void setAcceptConnectionTimeout(int acceptConnectionTimeout)
-