org.apache.logging.log4j.core.net.server
Class TcpSocketServer<T extends InputStream>

java.lang.Object
  extended by org.apache.logging.log4j.core.LogEventListener
      extended by org.apache.logging.log4j.core.net.server.AbstractSocketServer<T>
          extended by org.apache.logging.log4j.core.net.server.TcpSocketServer<T>
Type Parameters:
T - The kind of input stream read
All Implemented Interfaces:
Runnable, EventListener
Direct Known Subclasses:
SecureTcpSocketServer

public class TcpSocketServer<T extends InputStream>
extends AbstractSocketServer<T>

Listens for events over a socket connection.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.net.server.AbstractSocketServer
AbstractSocketServer.ServerConfigurationFactory
 
Field Summary
 
Fields inherited from class org.apache.logging.log4j.core.net.server.AbstractSocketServer
logEventInput, logger, MAX_PORT
 
Constructor Summary
TcpSocketServer(int port, LogEventBridge<T> logEventInput)
          Constructor.
TcpSocketServer(int port, LogEventBridge<T> logEventInput, ServerSocket serverSocket)
          Constructor.
 
Method Summary
static TcpSocketServer<InputStream> createJsonSocketServer(int port)
          Creates a socket server that reads JSON log events.
static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(int port)
          Creates a socket server that reads serialized log events.
static TcpSocketServer<InputStream> createXmlSocketServer(int port)
          Creates a socket server that reads XML log events.
static void main(String[] args)
          Main startup for the server.
 void run()
          Accept incoming events and processes them.
 void shutdown()
          Shutdown the server.
 
Methods inherited from class org.apache.logging.log4j.core.net.server.AbstractSocketServer
isActive, setActive, startNewThread
 
Methods inherited from class org.apache.logging.log4j.core.LogEventListener
log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpSocketServer

public TcpSocketServer(int port,
                       LogEventBridge<T> logEventInput)
                throws IOException
Constructor.

Parameters:
port - to listen.
logEventInput - the log even input
Throws:
IOException - if an I/O error occurs when opening the socket.

TcpSocketServer

public TcpSocketServer(int port,
                       LogEventBridge<T> logEventInput,
                       ServerSocket serverSocket)
                throws IOException
Constructor.

Parameters:
port - to listen.
logEventInput - the log even input
serverSocket - the socket server
Throws:
IOException - if an I/O error occurs when opening the socket.
Method Detail

createJsonSocketServer

public static TcpSocketServer<InputStream> createJsonSocketServer(int port)
                                                           throws IOException
Creates a socket server that reads JSON log events.

Parameters:
port - the port to listen
Returns:
a new a socket server
Throws:
IOException - if an I/O error occurs when opening the socket.

createSerializedSocketServer

public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(int port)
                                                                       throws IOException
Creates a socket server that reads serialized log events.

Parameters:
port - the port to listen
Returns:
a new a socket server
Throws:
IOException - if an I/O error occurs when opening the socket.

createXmlSocketServer

public static TcpSocketServer<InputStream> createXmlSocketServer(int port)
                                                          throws IOException
Creates a socket server that reads XML log events.

Parameters:
port - the port to listen
Returns:
a new a socket server
Throws:
IOException - if an I/O error occurs when opening the socket.

main

public static void main(String[] args)
                 throws Exception
Main startup for the server.

Parameters:
args - The command line arguments.
Throws:
Exception - if an error occurs.

run

public void run()
Accept incoming events and processes them.


shutdown

public void shutdown()
              throws IOException
Shutdown the server.

Throws:
IOException


Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.