I have enabled SOAP logging by adding following in standalone.xml as described in Jboss Advanced User Guide:
<system-properties>
<property name="org.apache.cxf.logging.enabled" value="true"/>
</system-properties>
This configuration does not pretty print XML messages. I am sure that CXF supports pretty printing since there is a AbstractLoggingInterceptor.setPrettyLogging()
method in the library.
How can I enable pretty printing of SOAP requests and responses in JBoss 7.
You can use the web console or CLI to easily do this which will not require a restart. In CLI it's simply /subsystem=logging/root-logger=ROOT:write-attribute(name=level, value=INFO) .
By default, JBoss produces output to both the console and a log file ( log/server. log ). There are six basic log levels in log4j: TRACE , DEBUG , INFO , WARN , ERROR and FATAL .
Using org.apache.cxf.logging.enabled property is the right way, it accepts value "pretty" for nicely formatted xml output
<system-properties>
<property name="org.apache.cxf.logging.enabled" value="pretty"/>
</system-properties>
For details see https://github.com/apache/cxf/blob/master/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java#L68-L72
Even though Serdal's answer is correct, it does not look practical to me.
My solution
I removed org.apache.cxf.logging.enabled
system property and used following code to enable SOAP logging:
Client client = ClientProxy.getClient(port);
LoggingInInterceptor inInterceptor = new LoggingInInterceptor();
inInterceptor.setPrettyLogging(true);
client.getInInterceptors().add(inInterceptor);
LoggingOutInterceptor outInterceptor = new LoggingOutInterceptor();
outInterceptor.setPrettyLogging(true);
client.getOutInterceptors().add(outInterceptor);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With