com.wowza.wms.logging
Class UDPAppender

Object
  extended by org.apache.log4j.AppenderSkeleton
      extended by com.wowza.wms.logging.UDPAppender
All Implemented Interfaces:
com.wowza.wms.logging.NetworkBased, com.wowza.wms.logging.PortBased, org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class UDPAppender
extends org.apache.log4j.AppenderSkeleton
implements com.wowza.wms.logging.PortBased

Sends log information as a UDP datagrams.

The UDPAppender is meant to be used as a diagnostic logging tool so that logging can be monitored by a simple UDP client.

Messages are not sent as LoggingEvent objects but as text after applying the designated Layout.

The port and remoteHost properties can be set in configuration properties. By setting the remoteHost to a broadcast address any number of clients can listen for log messages.

This was inspired and really extended/copied from SocketAppender. Please see the docs for the proper credit to the authors of that class.


Field Summary
static int DEFAULT_PORT
          The default port number for the UDP packets, 9991.
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
UDPAppender()
           
UDPAppender(java.net.InetAddress address, int port)
          Sends UDP packets to the address and port.
UDPAppender(String host, int port)
          Sends UDP packets to the address and port.
 
Method Summary
 void activateOptions()
          Open the UDP sender for the RemoteHost and Port.
 void append(org.apache.log4j.spi.LoggingEvent event)
           
 void cleanUp()
          Close the UDP Socket and release the underlying connector thread if it has been created
 void close()
          Close this appender.
 String getApplication()
          Returns value of the App option.
 String getEncoding()
          Returns value of the Encoding option.
 int getPort()
          Returns value of the Port option.
 String getRemoteHost()
          Returns value of the RemoteHost option.
 boolean isActive()
          Get if item is active.
 boolean requiresLayout()
          The UDPAppender uses layouts.
 void setApplication(String app)
          The App option takes a string value which should be the name of the application getting logged.
 void setEncoding(String encoding)
          The Encoding option specifies how the bytes are encoded.
 void setPort(int port)
          The Port option takes a positive integer representing the port where UDP packets will be sent.
 void setRemoteHost(String host)
          The RemoteHost option takes a string value which should be the host name or ipaddress to send the UDP packets.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.wowza.wms.logging.NetworkBased
getName
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The default port number for the UDP packets, 9991.

See Also:
Constant Field Values
Constructor Detail

UDPAppender

public UDPAppender()

UDPAppender

public UDPAppender(java.net.InetAddress address,
                   int port)
Sends UDP packets to the address and port.


UDPAppender

public UDPAppender(String host,
                   int port)
Sends UDP packets to the address and port.

Method Detail

activateOptions

public void activateOptions()
Open the UDP sender for the RemoteHost and Port.

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

append

public void append(org.apache.log4j.spi.LoggingEvent event)
Specified by:
append in class org.apache.log4j.AppenderSkeleton

cleanUp

public void cleanUp()
Close the UDP Socket and release the underlying connector thread if it has been created


close

public void close()
Close this appender.

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

Specified by:
close in interface org.apache.log4j.Appender

getApplication

public String getApplication()
Returns value of the App option.


getEncoding

public String getEncoding()
Returns value of the Encoding option.


getPort

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

Specified by:
getPort in interface com.wowza.wms.logging.PortBased
Returns:
int port number

getRemoteHost

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


isActive

public boolean isActive()
Description copied from interface: com.wowza.wms.logging.NetworkBased
Get if item is active.

Specified by:
isActive in interface com.wowza.wms.logging.NetworkBased
Returns:
if true, item is active.

requiresLayout

public boolean requiresLayout()
The UDPAppender uses layouts. Hence, this method returns true.

Specified by:
requiresLayout in interface org.apache.log4j.Appender

setApplication

public void setApplication(String app)
The App option takes a string value which should be the name of the application getting logged. If property was already set (via system property), don't set here.


setEncoding

public void setEncoding(String encoding)
The Encoding option specifies how the bytes are encoded. If this option is not specified, the System encoding is used.


setPort

public void setPort(int port)
The Port option takes a positive integer representing the port where UDP packets will be sent.


setRemoteHost

public void setRemoteHost(String host)
The RemoteHost option takes a string value which should be the host name or ipaddress to send the UDP packets.