Using the log4j system to observe SOAP message
Log4j is an apache project to log run time information. You can use Log4J to observe SOAP message at both client side and server side. More than that, you can also observe other operations Tomcat executes. Be default, this system is not available. You may have already noticed the warn message about the loggers when you run axis applications.
First, save the code in the following block into a file name log4j.properties. This log4j configuration file is for logging the SOAP relevant information in file “axis.log”.
# Set root logger level to WARN and its only appender to A1. log4j.rootLogger=WARN, A1 # show DEBUG for SOAPPart method log4j.logger.org.apache.axis.SOAPPart=DEBUG # A1 is set to be a ConsoleAppender. # log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1=org.apache.log4j.FileAppender log4j.appender.A1.File=axis.log # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Second, use it for logging client side SOAP messages: Copy log4j.properties in the directory where the java command runs. Java will find the configuration file and use it automatically. E.g.
java samples.stock.GetQuote -uuser1 -wpass1 XXX
Or use the option –D to indicate the configuration file:
java -Dlog4j.configuration=file:log4j.properties samples.stock.GetQuote -uuser1 -wpass1 XXX
You will find the file axis.log at the same directory which records the SOAP messages.
Third, use it for logging server side SOAP messages: Copy the log4j.properties into the directory where axis engine starts:
You will find the log file at the directory where you start the tomcat server. On my computer is at
ORIGINAL ARTICLE: http://personal.nbnet.nb.ca/dragonfy/ebcourse/Lecture3/Log4j.pdf