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.

http://www.mkyong.com/java/jaxb-hello-world-example/

jaxbMarshaller.marshal(customer, System.out);

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??

Answers


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());

Need Your Help

Custom SSL Certificate Authority?

ssl certificate-authority

Is there a custom SSL certificate authority I can add to my browser?

How can I style a progress bar to look like Material Design ? (see picture)

android android-layout progress-bar

I need to style my progress bar to look like the one above. Any ideas? Thanks. I actually was wondering if I could STYLE a ProgressBar to look like this WITHOUT using SwipeRefreshLayout. Sorry I

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.