Return-Path: Delivered-To: apmail-incubator-cxf-issues-archive@locus.apache.org Received: (qmail 31295 invoked from network); 21 Dec 2007 13:52:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Dec 2007 13:52:06 -0000 Received: (qmail 68406 invoked by uid 500); 21 Dec 2007 13:51:55 -0000 Delivered-To: apmail-incubator-cxf-issues-archive@incubator.apache.org Received: (qmail 68396 invoked by uid 500); 21 Dec 2007 13:51:55 -0000 Mailing-List: contact cxf-issues-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-issues@incubator.apache.org Received: (qmail 68387 invoked by uid 99); 21 Dec 2007 13:51:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Dec 2007 05:51:55 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Dec 2007 13:51:52 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 18C2B714241 for ; Fri, 21 Dec 2007 05:51:43 -0800 (PST) Message-ID: <28175773.1198245103089.JavaMail.jira@brutus> Date: Fri, 21 Dec 2007 05:51:43 -0800 (PST) From: "Davide Gesino (JIRA)" To: cxf-issues@incubator.apache.org Subject: [jira] Created: (CXF-1327) Logging Interceptor with pretty formatting MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Logging Interceptor with pretty formatting ------------------------------------------ Key: CXF-1327 URL: https://issues.apache.org/jira/browse/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 .getLog(PrettyLoggingOutInterceptor.class); private SAXBuilder saxBuilder = new SAXBuilder(); private XMLOutputter xmlOutputter = new XMLOutputter(); public PrettyLoggingOutInterceptor() { super(Phase.PRE_STREAM); addBefore(StaxOutInterceptor.class.getName()); } public void handleMessage(Message message) throws Fault { final OutputStream os = message.getContent(OutputStream.class); if (os == null) { return; } if (!LOG.isInfoEnabled()) { return; } // 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 = saxBuilder.build(cos.getInputStream()); xmlOutputter.setFormat(Format.getPrettyFormat()); StringWriter writer = new StringWriter(); xmlOutputter.output(jdoCument, writer); LOG.info(writer.getBuffer().toString()); } catch (Exception e) { LOG.error("fatal parsing the SOAP message"); LOG.error(e); } } } } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.