Class DatagramOutputTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.AbstractOutputTarget
org.apache.log.output.net.DatagramOutputTarget
- All Implemented Interfaces:
ErrorAware, LogTarget, Closeable
A datagram output target.
Useful for writing using custom protocols or writing to syslog daemons.
- Author:
- Avalon Development Team, Peter Donald
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringDefault encoding of datagramprivate StringThe encoding to use when creating byte array from stringprivate DatagramSocketSocket on which to send datagrams -
Constructor Summary
ConstructorsConstructorDescriptionDatagramOutputTarget(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
Methods inherited from class AbstractOutputTarget
doProcessEvent, getFormatter, openMethods inherited from class AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
-
Field Details
-
DEFAULT_ENCODING
-
m_socket
Socket on which to send datagrams -
m_encoding
The encoding to use when creating byte array from string
-
-
Constructor Details
-
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 endpointport- the address portformatter- the message formatterencoding- the encoding to use when encoding string- Throws:
IOException- if an error occurs
-
DatagramOutputTarget
Create a output target with end point specified by address and port.- Parameters:
address- the address endpointport- the address portformatter- the message formatter- Throws:
IOException- if an error occurs
-
DatagramOutputTarget
Create a output target with end point specified by address and port.- Parameters:
address- the address endpointport- the address port- Throws:
IOException- if an error occurs
-
-
Method Details
-
write
Method to write output to datagram.- Overrides:
writein classAbstractOutputTarget- Parameters:
stringData- the data to be output
-
close
public void close()Shutdown target. Attempting to write to target after close() will cause errors to be logged.- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractOutputTarget
-