Package org.apache.log.output.net
Class SocketOutputTarget
- java.lang.Object
-
- org.apache.log.output.AbstractTarget
-
- org.apache.log.output.AbstractOutputTarget
-
- org.apache.log.output.net.SocketOutputTarget
-
- All Implemented Interfaces:
ErrorAware,LogTarget,Closeable
public class SocketOutputTarget extends AbstractOutputTarget
SocketOutputTarget Useful for writing the output to a TCP/IP client socket.- Author:
- Rajendra Ghorpade
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.ObjectOutputStreamm_outputStreamOutput strem to write the logprivate java.net.Socketm_socketSocket to communicate with the server
-
Constructor Summary
Constructors Constructor Description SocketOutputTarget(java.lang.String host, int port)Creates the output target with the end point specified by host and portSocketOutputTarget(java.net.InetAddress address, int port)Creates output target with the end point specified by the address and port
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Shutdown target.protected voiddoProcessEvent(LogEvent event)To process the LogEventprotected voidwrite(LogEvent event)Writes the output as a LogEvent without formatting.-
Methods inherited from class org.apache.log.output.AbstractOutputTarget
getFormatter, open, write
-
Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
-
-
-
-
Constructor Detail
-
SocketOutputTarget
public SocketOutputTarget(java.net.InetAddress address, int port) throws java.io.IOExceptionCreates output target with the end point specified by the address and port- Parameters:
address- end point addressport- the end point port- Throws:
java.io.IOException- if an I/O error ocurrs when creating socket
-
SocketOutputTarget
public SocketOutputTarget(java.lang.String host, int port) throws java.io.IOExceptionCreates the output target with the end point specified by host and port- Parameters:
host- end point hostport- the end point port- Throws:
java.io.IOException- if an I/O error ocurrs when creating socket
-
-
Method Detail
-
write
protected void write(LogEvent event)
Writes the output as a LogEvent without formatting. Formatting ia applied on the server side where it is log.- Parameters:
event- the LogEvent
-
doProcessEvent
protected void doProcessEvent(LogEvent event)
To process the LogEvent- Overrides:
doProcessEventin classAbstractOutputTarget- Parameters:
event- the LogEvent
-
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
-
-