public class LogstashTcpSocketAppender
extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
implements java.lang.Runnable, ch.qos.logback.core.net.SocketConnector.ExceptionHandler
SocketAppender
. The queue type and
the dispatch method is different than the original version. ClassicConstants.FINALIZE_SESSION_MARKER
is sent. logger.info(ClassicConstants.FINALIZE_SESSION_MARKER, "About to end the job");
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORT
The default port number of remote logging server (4560).
|
static int |
DEFAULT_QUEUE_SIZE
Default size of the queue used to hold logging events that are destined
for the remote peer.
|
static int |
DEFAULT_RECONNECTION_DELAY
The default reconnection delay (30000 milliseconds or 30 seconds).
|
protected ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> |
encoder
It is the encoder which is ultimately responsible for writing the event
to an
OutputStream . |
Constructor and Description |
---|
LogstashTcpSocketAppender() |
Modifier and Type | Method and Description |
---|---|
protected void |
append(ch.qos.logback.classic.spi.ILoggingEvent event) |
void |
connectionFailed(ch.qos.logback.core.net.SocketConnector connector,
java.lang.Exception ex) |
protected void |
encoderClose(java.io.OutputStream outputStream) |
protected void |
encoderInit(java.io.OutputStream outputStream) |
ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> |
getEncoder() |
ch.qos.logback.core.util.Duration |
getEventDelayLimit()
Returns the value of the eventDelayLimit property.
|
int |
getPort()
Returns value of the Port property.
|
ch.qos.logback.core.spi.PreSerializationTransformer<ch.qos.logback.classic.spi.ILoggingEvent> |
getPST()
Get the pre-serialization transformer that will be used to transform each
event into a Serializable object before delivery to the remote receiver.
|
ch.qos.logback.core.util.Duration |
getReconnectionDelay()
Returns value of the reconnectionDelay property.
|
java.lang.String |
getRemoteHost()
Returns value of the RemoteHost property.
|
protected javax.net.SocketFactory |
getSocketFactory()
Gets the default
SocketFactory for the platform. |
protected ch.qos.logback.core.net.SocketConnector |
newConnector(java.net.InetAddress address,
int port,
long initialDelay,
long retryDelay)
Creates a new
SocketConnector . |
void |
run() |
void |
setEncoder(ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> encoder) |
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 |
setPort(int port)
The Port property takes a positive integer representing the port
where the server is waiting for connections.
|
void |
setReconnectionDelay(ch.qos.logback.core.util.Duration delay)
The reconnectionDelay property takes a positive
Duration value representing the time to wait between each failed connection
attempt to the server. |
void |
setRemoteHost(java.lang.String host)
The RemoteHost property takes the name of of the host where a
corresponding server is running.
|
void |
start() |
void |
stop() |
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toString
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
public static final int DEFAULT_PORT
public static final int DEFAULT_RECONNECTION_DELAY
public static final int DEFAULT_QUEUE_SIZE
protected ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> encoder
OutputStream
.public ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> getEncoder()
public void setEncoder(ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> encoder)
encoder
- the encoder to setpublic ch.qos.logback.core.spi.PreSerializationTransformer<ch.qos.logback.classic.spi.ILoggingEvent> getPST()
protected void encoderInit(java.io.OutputStream outputStream)
protected void encoderClose(java.io.OutputStream outputStream)
public void start()
start
in interface ch.qos.logback.core.spi.LifeCycle
start
in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
public void stop()
stop
in interface ch.qos.logback.core.spi.LifeCycle
stop
in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
protected void append(ch.qos.logback.classic.spi.ILoggingEvent event)
append
in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
public final void run()
run
in interface java.lang.Runnable
public void connectionFailed(ch.qos.logback.core.net.SocketConnector connector, java.lang.Exception ex)
connectionFailed
in interface ch.qos.logback.core.net.SocketConnector.ExceptionHandler
protected ch.qos.logback.core.net.SocketConnector newConnector(java.net.InetAddress address, int port, long initialDelay, long retryDelay)
SocketConnector
.
The default implementation creates an instance of DefaultSocketConnector
. A subclass may override to provide a different SocketConnector
implementation.
address
- target remote addressport
- target remote portinitialDelay
- delay before the first connection attemptretryDelay
- delay before a reconnection attemptprotected javax.net.SocketFactory getSocketFactory()
SocketFactory
for the platform.
Subclasses may override to provide a custom socket factory.
public void setRemoteHost(java.lang.String host)
public java.lang.String getRemoteHost()
public void setPort(int port)
public int getPort()
public void setReconnectionDelay(ch.qos.logback.core.util.Duration delay)
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.
public ch.qos.logback.core.util.Duration getReconnectionDelay()
public void setEventDelayLimit(ch.qos.logback.core.util.Duration eventDelayLimit)
eventDelayLimit
- the event delay limitpublic ch.qos.logback.core.util.Duration getEventDelayLimit()
Copyright © 2014. All Rights Reserved.