org.apache.log.output.net

Class DatagramOutputTarget

Implemented Interfaces:
Closeable, ErrorAware, LogTarget

public class DatagramOutputTarget
extends AbstractOutputTarget

A datagram output target. Useful for writing using custom protocols or writing to syslog daemons.
Authors:
Avalon Development Team
Peter Donald

Field Summary

private static String
DEFAULT_ENCODING
private String
m_encoding
private DatagramSocket
m_socket

Fields inherited from class org.apache.log.output.AbstractOutputTarget

m_formatter

Fields inherited from class org.apache.log.output.AbstractTarget

DEFAULT_ERROR_HANDLER, m_errorHandler, m_isOpen

Constructor Summary

DatagramOutputTarget(InetAddress address, int port)
Create a output target with end point specified by address and port.
DatagramOutputTarget(InetAddress address, int port, Formatter formatter)
Create a output target with end point specified by address and port.
DatagramOutputTarget(InetAddress address, int port, Formatter formatter, String encoding)
Create a output target with end point specified by address and port.

Method Summary

void
close()
Shutdown target.
protected void
write(String stringData)
Method to write output to datagram.

Methods inherited from class org.apache.log.output.AbstractOutputTarget

close, doProcessEvent, format, getFormatter, getHead, getTail, open, write, writeHead, writeTail

Methods inherited from class org.apache.log.output.AbstractTarget

close, doProcessEvent, getErrorHandler, isOpen, open, processEvent, setErrorHandler

Field Details

DEFAULT_ENCODING

private static final String DEFAULT_ENCODING

m_encoding

private String m_encoding

m_socket

private DatagramSocket m_socket

Constructor Details

DatagramOutputTarget

public DatagramOutputTarget(InetAddress address,
                            int port)
            throws IOException
Create a output target with end point specified by address and port.
Parameters:
address - the address endpoint
port - the address port

DatagramOutputTarget

public DatagramOutputTarget(InetAddress address,
                            int port,
                            Formatter formatter)
            throws IOException
Create a output target with end point specified by address and port.
Parameters:
address - the address endpoint
port - the address port
formatter - the message formatter

DatagramOutputTarget

public DatagramOutputTarget(InetAddress address,
                            int port,
                            Formatter formatter,
                            String encoding)
            throws IOException
Create a output target with end point specified by address and port.
Parameters:
address - the address endpoint
port - the address port
formatter - the message formatter
encoding - the encoding to use when encoding string

Method Details

close

public void close()
Shutdown target. Attempting to write to target after close() will cause errors to be logged.
Specified by:
close in interface Closeable
Overrides:
close in interface AbstractOutputTarget

write

protected void write(String stringData)
Method to write output to datagram.
Overrides:
write in interface AbstractOutputTarget
Parameters:
stringData - the data to be output