private static void dumpTailOfLog(File f, PrintWriter out, long tailKb) throws IOException {
    FileInputStream fis = new FileInputStream(f);
    BufferedReader r = null;
    try {
      FileChannel channel = fis.getChannel();
      channel.position(Math.max(0, channel.size() - tailKb * 1024));
      r = new BufferedReader(new InputStreamReader(fis, StandardCharsets.UTF_8));
      r.readLine(); // skip the first partial line
      String line;
      while ((line = r.readLine()) != null) {
        out.println(line);
      }
    } finally {
      if (r != null) IOUtils.closeStream(r);
      IOUtils.closeStream(fis);
    }
  }
Utility functions for reading the log4j logs that are being written by HBase.
hbase-http/src/main/java/org/apache/hadoop/hbase/util/LogMonitoring.java