Enabling SOAP Request and Response Logging in JBoss EAP 7
Dhanusha Perera

Dhanusha Perera @dhanushaperera07

About: I'm a Senior Software Engineer with strong experience in building and optimizing ERP systems.

Location:
Colombo, Sri Lanka
Joined:
Feb 23, 2021

Enabling SOAP Request and Response Logging in JBoss EAP 7

Publish Date: Mar 11
0 0

Logging SOAP request and response messages in JBoss EAP 7 can help with debugging and monitoring. This guide walks through configuring JBoss to log JAX-WS messages without restarting the server.

Step 1: Configure Logging in standalone.xml

Modify the standalone.xml file to include a periodic rotating file handler and loggers for JAX-WS:

Add the Periodic Rotating File Handler

Insert the following under <subsystem xmlns="urn:jboss:domain:logging:...">:

<periodic-rotating-file-handler name="JaxWsFileHandler" autoflush="true">
    <formatter>
        <named-formatter name="PATTERN"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="myapp_soap_requests.log"/>
    <suffix value=".yyyy-MM-dd"/>
    <append value="true"/>
</periodic-rotating-file-handler>
Enter fullscreen mode Exit fullscreen mode

Add Loggers for JAX-WS

Insert the following inside the <subsystem xmlns="urn:jboss:domain:logging:..."> section:

<logger category="com.sun.xml.ws">
    <level name="FINE"/>
    <handlers>
        <handler name="JaxWsFileHandler"/>
    </handlers>
</logger>
<logger category="com.sun.xml.ws.transport.http">
    <level name="FINEST"/>
    <handlers>
        <handler name="JaxWsFileHandler"/>
    </handlers>
</logger>
<logger category="com.sun.xml.ws.server">
    <level name="FINEST"/>
    <handlers>
        <handler name="JaxWsFileHandler"/>
    </handlers>
</logger>
Enter fullscreen mode Exit fullscreen mode

Step 2: Enable SOAP Message Dumping in standalone.conf

Edit standalone.conf to add the required system properties:

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dumpTreshold=2147483647"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold=2147483647"
Enter fullscreen mode Exit fullscreen mode

Step 3: Apply Changes Without Restarting JBoss (Optional)

If you cannot restart JBoss, use the CLI to apply logging changes dynamically:

Add the Logging Handler

Run the following command in JBoss CLI:

/subsystem=logging/periodic-rotating-file-handler=JaxWsFileHandler:add(autoflush=true, file={"relative-to" => "jboss.server.log.dir", "path" => "myapp_soap_requests.log"}, suffix=".yyyy-MM-dd", append=true, named-formatter="PATTERN")
Enter fullscreen mode Exit fullscreen mode

Add Loggers

/logger=com.sun.xml.ws:add(level=FINE, handlers=["JaxWsFileHandler"])
/logger=com.sun.xml.ws.transport.http:add(level=FINEST, handlers=["JaxWsFileHandler"])
/logger=com.sun.xml.ws.server:add(level=FINEST, handlers=["JaxWsFileHandler"])
Enter fullscreen mode Exit fullscreen mode

Step 4: Verify Logs

Once configured, you should see SOAP request and response logs in myapp_soap_requests.log under the JBoss log directory.

Why This Solution Matters

This logging setup is crucial for debugging and monitoring SOAP web services. It allows developers to inspect incoming and outgoing SOAP messages, making it easier to identify issues, optimize performance, and ensure compliance with API requirements. The ability to apply these changes dynamically without a restart ensures minimal downtime and enhances production debugging capabilities.

What You Can Do with This Solution

  • Debug SOAP Issues: Capture full request and response payloads for troubleshooting.
  • Monitor API Activity: Track SOAP messages to ensure correct integration and detect anomalies.
  • Enhance Security Auditing: Log SOAP traffic for compliance and security reviews.
  • Minimize Downtime: Make logging adjustments dynamically without restarting JBoss.

Following this guide ensures SOAP messages are logged efficiently without requiring a server restart. Let me know if you encounter issues!

Comments 0 total

    Add comment