cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davide Gesino (JIRA)" <>
Subject [jira] Created: (CXF-1327) Logging Interceptor with pretty formatting
Date Fri, 21 Dec 2007 13:51:43 GMT
Logging Interceptor with pretty formatting

                 Key: CXF-1327
             Project: CXF
          Issue Type: Wish
          Components: Tooling
            Reporter: Davide Gesino
            Priority: Trivial

LoggingInIterceptor and LoggingOutInterceptor are really useful, but sometimes it is difficult
to read the SOAP messages without having a "pretty" identation, I would a LOG that  outputs
a nice formatted string with XML identation.
Modifying the LoggingOutInterceptor something similar to the example I paste in the following,
obtained modifying the LoggingOutInterceptor.
I hav not included the length limit and used the jdom api instead of stax.

public class PrettyLoggingOutInterceptor extends AbstractPhaseInterceptor {

	private final Log LOG = LogFactory

	private SAXBuilder saxBuilder = new SAXBuilder();
	private XMLOutputter xmlOutputter = new XMLOutputter();

	public PrettyLoggingOutInterceptor() {

	public void handleMessage(Message message) throws Fault {
		final OutputStream os = message.getContent(OutputStream.class);
		if (os == null) {
		if (!LOG.isInfoEnabled()) {

		// Write the output while caching it for the log message
		final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(	os);
		message.setContent(OutputStream.class, newOut);
		newOut.registerCallback(new LoggingCallback());

	class LoggingCallback implements CachedOutputStreamCallback {

		public void onFlush(CachedOutputStream cos) {


		public void onClose(CachedOutputStream cos) {

			try {
				Document jdoCument =;
				StringWriter writer = new StringWriter();
				xmlOutputter.output(jdoCument, writer);;
			} catch (Exception e) {
				LOG.error("fatal parsing the SOAP message");

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message