new SocketHandler(String host, int port) : SocketHandler « java.util.logging « Java by API






new SocketHandler(String host, int port)

  

import java.io.IOException;
import java.util.logging.Logger;
import java.util.logging.SocketHandler;

public class Main {
  private SocketHandler handler = null;

  private static Logger logger = Logger.getLogger("sam.logging");

  public Main(String host, int port) {
    try {
      handler = new SocketHandler(host, port);
      logger.addHandler(handler);
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }

  public void logMessage() {
    logger.warning("SocketHandler is working...");
  }

  public static void main(String args[]) {
    Main demo = new Main ("localhost", 2020);
    demo.logMessage();
  }
}

   
    
  








Related examples in the same category