public synchronized void writeEvent(long timestamp, String componentName, String streamId, Set<String> targetComponents, StreamlineEvent event) { try (FileWriter fw = new FileWriter(eventLogFilePath, true)) { LOG.debug("writing event to file " + eventLogFilePath); EventInformationBuilder informationBuilder = new EventInformationBuilder(); EventInformation eventInfo = informationBuilder.build(timestamp, componentName, streamId, targetComponents, event); fw.write(objectMapper.writeValueAsString(eventInfo) + "\n"); fw.flush(); } catch (FileNotFoundException e) { LOG.error("Can't open file for write: " + eventLogFilePath); throw new RuntimeException(e); } catch (IOException e) { LOG.error("Fail to write event to output file " + eventLogFilePath + " : exception occurred.", e); throw new RuntimeException(e); } }