Log4j 2.0alpha-1

org.apache.log4j.net
Class XMLSocketReceiver

java.lang.Object
  extended by org.apache.log4j.spi.ComponentBase
      extended by org.apache.log4j.plugins.PluginSkeleton
          extended by org.apache.log4j.plugins.Receiver
              extended by org.apache.log4j.net.XMLSocketReceiver
All Implemented Interfaces:
java.lang.Runnable, org.apache.log4j.net.NetworkBased, org.apache.log4j.net.PortBased, org.apache.log4j.plugins.Pauseable, org.apache.log4j.plugins.Plugin, org.apache.log4j.spi.Component, org.apache.log4j.spi.OptionHandler, org.apache.log4j.spi.Thresholdable

public class XMLSocketReceiver
extends Receiver
implements java.lang.Runnable, org.apache.log4j.net.PortBased, org.apache.log4j.plugins.Pauseable

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).

Once the event has been "posted", it will be handled by the appenders currently configured in the LoggerRespository.

Since:
1.3
Author:
Mark Womack, Scott Deboy

Field Summary
protected  boolean active
           
protected  java.lang.String decoder
           
static int DEFAULT_PORT
           
protected  int port
           
 
Fields inherited from class org.apache.log4j.plugins.Receiver
thresholdLevel
 
Fields inherited from class org.apache.log4j.plugins.PluginSkeleton
name
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
XMLSocketReceiver()
           
XMLSocketReceiver(int _port)
           
XMLSocketReceiver(int _port, org.apache.log4j.spi.LoggerRepository _repository)
           
 
Method Summary
 void activateOptions()
          Starts the SocketReceiver with the current options.
 void doPost(org.apache.log4j.spi.LoggingEvent event)
          Posts the logging event to a logger in the configured logger repository.
 java.lang.String getDecoder()
           
 int getPort()
          Get the port to receive logging events on.
 int hashCode()
           
 boolean isActive()
          Returns true if this receiver is active.
 boolean isEquivalent(org.apache.log4j.plugins.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.
 boolean isPaused()
           
 void run()
          Loop, accepting new socket connections.
 void setDecoder(java.lang.String _decoder)
           
 void setPaused(boolean b)
           
 void setPort(int _port)
          Set the port to receive logging events on.
 void shutdown()
          Called when the receiver should be stopped.
 
Methods inherited from class org.apache.log4j.plugins.Receiver
getThreshold, isAsSevereAsThreshold, setThreshold
 
Methods inherited from class org.apache.log4j.plugins.PluginSkeleton
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setName
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, getNonFloodingLogger, resetErrorCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.log4j.net.NetworkBased
getName
 

Field Detail

active

protected boolean active

decoder

protected java.lang.String decoder

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

port

protected int port
Constructor Detail

XMLSocketReceiver

public XMLSocketReceiver()

XMLSocketReceiver

public XMLSocketReceiver(int _port)

XMLSocketReceiver

public XMLSocketReceiver(int _port,
                         org.apache.log4j.spi.LoggerRepository _repository)
Method Detail

getPort

public int getPort()
Get the port to receive logging events on.

Specified by:
getPort in interface org.apache.log4j.net.PortBased

setPort

public void setPort(int _port)
Set the port to receive logging events on.


getDecoder

public java.lang.String getDecoder()

setDecoder

public void setDecoder(java.lang.String _decoder)

isPaused

public boolean isPaused()
Specified by:
isPaused in interface org.apache.log4j.plugins.Pauseable

setPaused

public void setPaused(boolean b)
Specified by:
setPaused in interface org.apache.log4j.plugins.Pauseable

isEquivalent

public boolean isEquivalent(org.apache.log4j.plugins.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. This is used by PluginRegistry when determining if the a similarly configured receiver is being started.

Specified by:
isEquivalent in interface org.apache.log4j.plugins.Plugin
Overrides:
isEquivalent in class org.apache.log4j.plugins.PluginSkeleton
Parameters:
testPlugin - The plugin to test equivalency against.
Returns:
boolean True if the testPlugin is equivalent to this plugin.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isActive

public boolean isActive()
Returns true if this receiver is active.

Specified by:
isActive in interface org.apache.log4j.net.NetworkBased
Specified by:
isActive in interface org.apache.log4j.plugins.Plugin
Overrides:
isActive in class org.apache.log4j.plugins.PluginSkeleton

activateOptions

public void activateOptions()
Starts the SocketReceiver with the current options.

Specified by:
activateOptions in interface org.apache.log4j.spi.OptionHandler

shutdown

public void shutdown()
Called when the receiver should be stopped. Closes the server socket and all of the open sockets.

Specified by:
shutdown in interface org.apache.log4j.plugins.Plugin

run

public void run()
Loop, accepting new socket connections.

Specified by:
run in interface java.lang.Runnable

doPost

public void doPost(org.apache.log4j.spi.LoggingEvent event)
Description copied from class: Receiver
Posts the logging event to a logger in the configured logger repository.

Overrides:
doPost in class Receiver
Parameters:
event - the log event to post to the local log4j environment.

Log4j 2.0alpha-1

Copyright 2000-2003 Apache Software Foundation.