@Override public void printErrors(List<ErrorLogger.ErrorObject> errorObjs, String workingDir, String fileName) { File file = new File(workingDir, fileName); JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(Errors.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); Errors errors = new Errors(); for (ErrorLogger.ErrorObject errorObj : errorObjs) { ErrorType error = new ErrorType(); error.setValue(getErrorMsg(errorObj)); error.setLevel(getErrorLevel(errorObj)); errors.getError().add(error); } jaxbMarshaller.marshal(errors, file); } catch (JAXBException e) { throw new RuntimeException(e); } }