I have a java webservice.. I need to log the response before returning. I am trying to serialize as below:

ByteArrayOutputStream fos = new ByteArrayOutputStream();
ObjectOutputStream outStream = new ObjectOutputStream( fos );
outStream.writeObject( response );
outStream.flush();
return fos.toString();

But I see invalid characters all over. How should properly save this as an XML?
And this object is Serializable.

Thanks,