code: private void prepareClosedLogFilesForTransfer() {
          for (final File logFile : _stagingDir.listFiles((dir, name) -> name.startsWith(_logFilePrefix) && name.endsWith(CLOSED_FILE_SUFFIX))) {
              boolean moved;
              String fileName = logFile.getName().substring(0, logFile.getName().length() - CLOSED_FILE_SUFFIX.length()) + COMPRESSED_FILE_SUFFIX;
              try (FileInputStream fileIn = new FileInputStream(logFile);
                   FileOutputStream fileOut = new FileOutputStream(new File(logFile.getParentFile(), fileName));
                   GzipCompressorOutputStream gzipOut = new GzipCompressorOutputStream(fileOut)) {
  
                  ByteStreams.copy(fileIn, gzipOut);
                  moved = true;
              } catch (IOException e) {
                  _log.warn("Failed to compress audit log file: {}", logFile, e);
                  moved = false;
              }
  
              if (moved) {
                  if (!logFile.delete()) {
                      _log.warn("Failed to delete audit log file: {}", logFile);
                  }
              }
          }
      }
docs: This method takes all closed log files and GZIPs and renames them in preparation for transfer.  If the operation
  fails the original file is unmodified so the next call should attempt to prepare the file again.  This means
  the same file may be transferred more than once, but this guarantees that so long as the host remains active the
  file will eventually be transferred.