How to print jaxb to java object in to logger
Hi by following the below link i am able to convert JAXB to java object and print it in console using below statement.
But i want to print the output in logger.
ex)log.info(customer) or log.debug(customer)
I am using Apache log4j.Does anyone have any idea??
Below a possible way..
Customer customer = new Customer(); //set customer attributes JAXBContext jc = JAXBContext.newInstance(Customer.class); Marshaller marshaller = jc.createMarshaller(); StringWriter stringWriter = new StringWriter(); marshaller.marshal(customer, stringWriter ); log.info(stringWriter.toString());