Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable pretty logging of SOAP messages in JBoss 7

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.

like image 355
Halil Avatar asked Jan 07 '15 12:01

Halil


People also ask

How do I change the log level in JBoss EAP 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) .

What are the logging levels available in JBoss?

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 .


2 Answers

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

like image 118
Rostislav Svoboda Avatar answered Nov 01 '22 10:11

Rostislav Svoboda


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);
like image 22
Halil Avatar answered Nov 01 '22 11:11

Halil