private void writeEntry(LoggerEntry entry) {
        String fileName = currentFileName();
        Path file = spoolPath.resolve(processingPath).resolve(fileName);
        try {
            log.log(Level.FINEST, () -> "Writing entry " + entryCounter.get() + " (" + entry.serialize() + ") to file " + fileName);
            Files.writeString(file, entry.serialize() + "\n", StandardOpenOption.WRITE, StandardOpenOption.APPEND, StandardOpenOption.CREATE);
            firstWriteTimestamp.compareAndExchange(Instant.EPOCH, clock.instant());
            entryCounter.incrementAndGet();
            switchFileIfNeeded(file, fileName);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
Spooler that will write an entry to a file and read files that are ready to be sent.
Files are written in JSON Lines text file format.

@author hmusum
container-search/src/main/java/com/yahoo/search/logging/Spooler.java