예제 #1
0
  public LogDirectory(File dir, Pattern pattern) throws IOException {
    if (!dir.isDirectory()) {
      throw new IllegalArgumentException("Argument must be a directory, got: " + dir);
    }

    // Read the date from the first line of each file, and sort the files
    // accordingly
    for (File file : dir.listFiles(new PatternFilenameFilter(pattern))) {
      ApacheLogEntryIterator it = new ApacheLogEntryIterator(open(file), true);

      while (it.hasNext()) {
        Date date = it.next().getDate();
        // logger.debug("Found log file " + file.getAbsolutePath() + " with date " + date);
        dateToFile.put(date, file);
        it.close();
        break;
      }
    }
    logger.debug("Found log files: " + dateToFile);
  }
예제 #2
0
 @Override
 public void close() {
   if (itEntry != null) {
     itEntry.close();
   }
 }