ch.qos.logback.core.net
Class SocketAppenderBase<E>

java.lang.Object
  extended by ch.qos.logback.core.spi.ContextAwareBase
      extended by ch.qos.logback.core.AppenderBase<E>
          extended by ch.qos.logback.core.net.SocketAppenderBase<E>
All Implemented Interfaces:
Appender<E>, ContextAware, FilterAttachable<E>, LifeCycle

public abstract class SocketAppenderBase<E>
extends AppenderBase<E>

This is the base class for module specific SocketAppender implementations.

Author:
Ceki Gülcü, Sébastien Pennec

Field Summary
protected  InetAddress address
           
protected  int counter
           
protected  ObjectOutputStream oos
           
protected  int port
           
protected  int reconnectionDelay
           
protected  String remoteHost
          We remember host name as String in addition to the resolved InetAddress so that it can be returned via getOption().
 
Fields inherited from class ch.qos.logback.core.AppenderBase
name, started
 
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
 
Constructor Summary
SocketAppenderBase()
           
 
Method Summary
protected  void append(E event)
           
 void cleanUp()
          Drop the connection to the remote host and release the underlying connector thread if it has been created
protected static InetAddress getAddressByName(String host)
           
 int getPort()
          Returns value of the Port option.
protected abstract  PreSerializationTransformer<E> getPST()
           
 int getReconnectionDelay()
          Returns value of the ReconnectionDelay option.
 String getRemoteHost()
          Returns value of the RemoteHost option.
protected abstract  void postProcessEvent(E event)
           
 void setPort(int port)
          The Port option takes a positive integer representing the port where the server is waiting for connections.
 void setReconnectionDelay(int delay)
          The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait between each failed connection attempt to the server.
 void setRemoteHost(String host)
          The RemoteHost option takes a string value which should be the host name of the server where a SocketNode is running.
 void start()
          Start this appender.
 void stop()
          Strop this appender.
 
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 Detail

remoteHost

protected String remoteHost
We remember host name as String in addition to the resolved InetAddress so that it can be returned via getOption().


address

protected InetAddress address

port

protected int port

oos

protected ObjectOutputStream oos

reconnectionDelay

protected int reconnectionDelay

counter

protected int counter
Constructor Detail

SocketAppenderBase

public SocketAppenderBase()
Method Detail

start

public void start()
Start this appender.

Specified by:
start in interface LifeCycle
Overrides:
start in class AppenderBase<E>

stop

public void stop()
Strop this appender.

This will mark the appender as closed and call then cleanUp() method.

Specified by:
stop in interface LifeCycle
Overrides:
stop in class AppenderBase<E>

cleanUp

public void cleanUp()
Drop the connection to the remote host and release the underlying connector thread if it has been created


append

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

postProcessEvent

protected abstract void postProcessEvent(E event)

getPST

protected abstract PreSerializationTransformer<E> getPST()

getAddressByName

protected static InetAddress getAddressByName(String host)

setRemoteHost

public void setRemoteHost(String host)
The RemoteHost option takes a string value which should be the host name of the server where a SocketNode is running.


getRemoteHost

public String getRemoteHost()
Returns value of the RemoteHost option.


setPort

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


getPort

public int getPort()
Returns value of the Port option.


setReconnectionDelay

public void setReconnectionDelay(int delay)
The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait between each failed connection attempt to the server. The default value of this option is 30000 which corresponds to 30 seconds.

Setting this option to zero turns off reconnection capability.


getReconnectionDelay

public int getReconnectionDelay()
Returns value of the ReconnectionDelay option.



Copyright © 2005-2010 QOS.ch. All Rights Reserved.