Package org.apache.log.output.net
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 String
private String
private DatagramSocket
-
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 org.apache.log.output.AbstractOutputTarget
doProcessEvent, getFormatter, open
Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
-
Field Details
-
DEFAULT_ENCODING
- See Also:
-
m_socket
-
m_encoding
-
-
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:
write
in 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:
close
in interfaceCloseable
- Overrides:
close
in classAbstractOutputTarget
-