Welcome to JavaRanch.
Well, you'd need to parts: a server that accepts connections on a particular port, logs what it receives to a file, and sends it on to one or several of the connected clients; and a client that connects to the server, has fields for user input and text output, send the input to the server, and receives output from the server to display.
You can start by examining one of the many sample codes for Java client/server port communication, e.g.
this one.