Question

I would like to know how to utilize Log4J to log SOAP messages in WebSphere 7, I am using JAX-WS which uses AXIS2 engine that ships with WebSphere 7. I was able to log the SOAP messages using "tracing" in WebSphere but I would like to know if there is a way to use Log4J to log SOAP messages and use a File Appender.

I would appreciate if someone can tell me exactly how to configure it, I tried a few things but it did not work.

I did put log4j.properties file in WEB-INF/classes as follows but it does not log SOAP messages.

log4j.rootCategory=DEBUG, LOGFILE
log4j.logger.org.apache.axis2=DEBUG, LOGFILE
log4j.category.org.apache.axis2=DEBUG, LOGFILE
log4j.logger.org.apache.axis2.transport.http=DEBUG, LOGFILE
log4j.category.org.apache.axis2.transport.http=DEBUG, LOGFILE
log4j.logger.com.ibm.ws.websvcs=DEBUG, LOGFILE
log4j.category.com.ibm.ws.websvcs=DEBUG, LOGFILE

log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=C:/K1/logs/axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n

No correct solution

OTHER TIPS

WebSphere web service runtime uses WebSphere trace logging internally. You likely won't be able to direct the built-in web service traces to log4j by simply adding and configuring log4j to your web service consuming application.

However, you can use a JAX-WS standard handler to log requests and responses or faults to a log4j Logger fairly easily (but you'll have to write some code).

Here a GlassFish tutorial on JAX-WS handlers. Note that the demonstration handler logs SOAP messages to System.out; you'll want to use log4j.

This StackOverflow post contains a full-java-class example of a SOAP message logging handler and how to register the handler programmatically so that it is executed during message processing. It too uses System.out; you'd need to substitute something like log.debug(...) for out.println(...) to use log4j. You could then configure log4j with a file appender for this logger as you attempted above.

As a sidebar, if you are obtaining your service reference via @WebServiceRef you can declaratively define a handler via XML file referenced by @HandlerChain. An end-to-end IBM tutorial is here.

Configuring log4j is same as any other project. Make sure that log4j.xml or properties file is in the class path and log4j related jars.

can you post any errors or anything config files.

If you want to log the request and responses you create a SOAP handler to do it for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top