Class XMLSocketReceiver
java.lang.Object
org.apache.log4j.component.spi.ComponentBase
org.apache.log4j.component.plugins.PluginSkeleton
org.apache.log4j.component.plugins.Receiver
org.apache.log4j.receivers.net.XMLSocketReceiver
- All Implemented Interfaces:
Runnable, Pauseable, Plugin, Component, Thresholdable, NetworkBased, PortBased, org.apache.log4j.spi.OptionHandler
XMLSocketReceiver receives a remote logging event via XML on a configured
socket and "posts" it to a LoggerRepository as if the event were
generated locally. This class is designed to receive events from
the XMLSocketAppender class (or classes that send compatible events).
This receiver supports log files created using log4j's XMLLayout, as well as java.util.logging XMLFormatter (via the org.apache.log4j.spi.Decoder interface).
By default, log4j's XMLLayout is supported (no need to specify a decoder in that case).
To configure this receiver to support java.util.logging's XMLFormatter, specify a 'decoder' param of org.apache.log4j.xml.UtilLoggingXMLDecoder.
Once the event has been "posted", it will be handled by the appenders currently configured in the LoggerRespository.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprotected Stringstatic final intprivate booleanprotected intprivate Threadprivate ServerSocketprivate Listprivate org.apache.log4j.net.ZeroConfSupportstatic final StringThe MulticastDNS zone advertised by an XMLSocketReceiverFields inherited from class Receiver
thresholdLevelFields inherited from class PluginSkeleton
active, nameFields inherited from class ComponentBase
repository -
Constructor Summary
ConstructorsConstructorDescriptionXMLSocketReceiver(int _port) XMLSocketReceiver(int _port, org.apache.log4j.spi.LoggerRepository _repository) -
Method Summary
Modifier and TypeMethodDescriptionvoidStarts the SocketReceiver with the current options.private voidCloses all the connected sockets in the List.private voidCloses the server socket, if created.voiddoPost(org.apache.log4j.spi.LoggingEvent event) Posts the logging event to a logger in the configured logger repository.private voidDoes the actual shutting down by closing the server socket and any connected sockets that have been created.intgetPort()Get the port to receive logging events on.inthashCode()booleanbooleanisEquivalent(Plugin testPlugin) Returns true if the receiver is the same class and they are configured for the same properties, and super class also considers them to be equivalent.booleanisPaused()Get paused state.voidrun()Loop, accepting new socket connections.protected voidsetActive(boolean b) Sets the flag to indicate if receiver is active or not.voidsetAdvertiseViaMulticastDNS(boolean advertiseViaMulticastDNS) voidsetDecoder(String _decoder) Specify the class name implementing org.apache.log4j.spi.Decoder that can process the file.voidsetPaused(boolean b) Set paused state.voidsetPort(int _port) Set the port to receive logging events on.voidshutdown()Called when the receiver should be stopped.Methods inherited from class Receiver
getThreshold, isAsSevereAsThreshold, setThresholdMethods inherited from class PluginSkeleton
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, isActive, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setNameMethods inherited from class ComponentBase
getLogger, getNonFloodingLogger, resetErrorCountMethods inherited from class Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NetworkBased
getName, isActive
-
Field Details
-
paused
private boolean paused -
decoder
-
serverSocket
-
socketList
-
rThread
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
port
protected int port -
advertiseViaMulticastDNS
private boolean advertiseViaMulticastDNS -
zeroConf
private org.apache.log4j.net.ZeroConfSupport zeroConf -
ZONE
-
-
Constructor Details
-
XMLSocketReceiver
public XMLSocketReceiver() -
XMLSocketReceiver
public XMLSocketReceiver(int _port) -
XMLSocketReceiver
public XMLSocketReceiver(int _port, org.apache.log4j.spi.LoggerRepository _repository)
-
-
Method Details
-
getPort
-
setPort
public void setPort(int _port) Set the port to receive logging events on. -
getDecoder
-
setDecoder
Specify the class name implementing org.apache.log4j.spi.Decoder that can process the file. -
isPaused
-
setPaused
-
isEquivalent
Returns true if the receiver is the same class and they are configured for the same properties, and super class also considers them to be equivalent. This is used by PluginRegistry when determining if the a similarly configured receiver is being started.- Specified by:
isEquivalentin interfacePlugin- Overrides:
isEquivalentin classPluginSkeleton- Parameters:
testPlugin- The plugin to test equivalency against.- Returns:
- boolean True if the testPlugin is equivalent to this plugin.
-
hashCode
-
setActive
protected void setActive(boolean b) Sets the flag to indicate if receiver is active or not.- Parameters:
b- new value
-
activateOptions
public void activateOptions()Starts the SocketReceiver with the current options.- Specified by:
activateOptionsin interfaceorg.apache.log4j.spi.OptionHandler
-
setAdvertiseViaMulticastDNS
public void setAdvertiseViaMulticastDNS(boolean advertiseViaMulticastDNS) -
isAdvertiseViaMulticastDNS
public boolean isAdvertiseViaMulticastDNS() -
shutdown
-
doShutdown
private void doShutdown()Does the actual shutting down by closing the server socket and any connected sockets that have been created. -
closeServerSocket
private void closeServerSocket()Closes the server socket, if created. -
closeAllAcceptedSockets
private void closeAllAcceptedSockets()Closes all the connected sockets in the List. -
run
-
doPost
-