Share

February 10, 2009

Log Sping WebServiceMessage body to Log4J Logger

If you have a WebServiceMessage object and you have a need to log that message to a Log4j Logger this is some quick code to do just that...

Log log = LogFactory.getLog("LoggerName");
WebServiceMessage message = wsMessage;
ByteArrayOutputStream os = new ByteArrayOutputStream();
message.writeTo(os);
log.error(os.toString());