@Override
  public void run() {
    try {
      String line = null;
      while ((line = in.readLine()) != null) {
        logger.info(line);
        if (errLogs != null) {
          if (numErrLogLines++ < MAX_ERR_LOG_LINES_FOR_RPC) {
            errLogs.add(line);
          }
        }
      }
    } catch (IOException e) {
      if (callback.isAlive()) {
        logger.warn("I/O error in redirector thread.", e);
      } else {
        // When stopping the process we are redirecting from,
        // the streams might be closed during reading.
        // We should not log the related exceptions in a visible level
        // as they might mislead the user.
        logger.debug("I/O error in redirector thread while stopping the remote driver", e);
      }
    } catch (Exception e) {
      logger.warn("Error in redirector thread.", e);
    }
  }
Class used to redirect output read from a stream to a logger
common/src/java/org/apache/hadoop/hive/common/log/LogRedirector.java