public static void main(String... args) throws IOException {
    File logFile = null;
    File sortedFile = null;

    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-sortedFile")) {
        if (++i >= args.length) {
          usage("Missing sorted file name");
        }

        sortedFile = new File(args[i]);

      } else if (logFile == null) {
        File file = new File(args[i]);
        if (!file.exists()) {
          usage(String.format("File %s does not exist", file));
        }

        logFile = file;

      } else {
        usage(String.format("Extraneous command line: %s", args[i]));
      }
    }

    if (logFile == null) {
      usage("Missing filename");
    }

    try (InputStream logFileStream = new FileInputStream(logFile)) {

      PrintStream ps;
      if (sortedFile != null) {
        FileOutputStream fileOutputStream = new FileOutputStream(sortedFile);
        try {
          ps = new PrintStream(fileOutputStream, true);
        } catch (Exception ex) {
          fileOutputStream.close();
          throw ex;
        }
      } else {
        ps = out;
      }

      sortLogFile(logFileStream, new PrintWriter(ps, true));
    }

    ExitCode.NORMAL.doSystemExit();
  }
Prints usage information about this program
geode-core/src/main/java/org/apache/geode/internal/logging/SortLogFile.java