code: public void send(String msg) {
      try {
        Socket socket = new Socket(graphiteHost, graphitePort);
  
        try {
          Writer writer = new OutputStreamWriter(socket.getOutputStream());
          try {
            writer.write(msg);
            writer.flush();
          } finally {
            try {
              writer.close();
            } catch (IOException ioe) {
              //ignore, we want to see the outer exception if any
              LOGGER.info("could not close writer");
            }
          }
          if (connectionState != ConnectionState.SUCCESS) {
            LOGGER.info("Connection to graphite Host {}",
              ((connectionState == ConnectionState.UNKNOWN) ? "established" : "recovered"));
            connectionState = ConnectionState.SUCCESS;
          }
  
        } catch (IOException e) {
          String action = "write";
          handleException(e, action);
        } finally {
          socket.close();
        }
      } catch (IOException e) {
        String action = "connect";
        handleException(e, action);
      }
    }
docs: Part of this code taken from http://neopatel.blogspot.de/2011/04/logging-to-graphite-monitoring-tool.html