Colleagues, hello. I'm a little confused. I have a simple dataflow made on Mule like this http://snag.gy/cJkzg.jpg In fact it is a CXF SOAP web service.
Now i need to add response and request xml logging, but i don't know which way to select. As i understood from internet there is next approaches: 1. Add Mule Logger element 2. Under src/main/resources/META-INF/cxf/ (I have not this folder) create a file named org.apache.cxf.Logger with the following contents -
org.apache.cxf.common.logging.Log4jLogger
and then add logger into my \src\main\resources\log4j.properties file.
It seems that's all I knew
At the current moment my log4j.properties looks like:
log.dir=./logs datestamp=dd.MM.yyyy HH:mm:ss.SSS log4j.rootLogger=INFO, stdout, defaultLog, errorlog
all INFO logs log4j.appender.defaultLog=org.apache.log4j.RollingFileAppender
log4j.appender.defaultLog.Threshold=TRACE log4j.appender.file.MaxFileSize=5MB log4j.appender.file.MaxBackupIndex=10 log4j.appender.defaultLog.File=${log.dir}/serv.log log4j.appender.defaultLog.layout=org.apache.log4j.PatternLayout log4j.appender.defaultLog.layout.ConversionPattern=%d{${datestamp}} %-5p %c{1}:%L - %m%n log4j.appender.defaultLog.encoding=UTF-8
ERROR log log4j.appender.errorlog=org.apache.log4j.RollingFileAppender
log4j.appender.errorlog.Threshold=ERROR log4j.appender.file.MaxFileSize=5MB log4j.appender.file.MaxBackupIndex=10 log4j.appender.errorlog.File=${log.dir}/serv.err log4j.appender.errorlog.layout=org.apache.log4j.PatternLayout log4j.appender.errorlog.layout.ConversionPattern=%d{${datestamp}} %-5p %c{1}:%L - %m%n
log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Threshold=TRACE log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{${datestamp}} %-5p %c{1}:%L - %m%n log4j.appender.stdout.encoding=UTF-8
As you see this properties file does not support payload logging.
How to add request & response logging in my case? I will be grateful for any code samples.
Thank you.
UPDATE
I added interceptors into flow:
<?xml version="1.0"?>
<flow name="Flow1" name="Flow1">
<inbound-endpoint exchange-pattern="request-response" host="localhost" port="45555" path="wserv" name="HTTP"/>
<jaxws-service serviceClass="com.maya.ws.EndPoindImpl" name="CXF">
<inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
</inInterceptors>
<outInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
</outInterceptors>
</jaxws-service>
<component class="com.maya.ws.EndPoindImpl" name="Java"/>
</flow>
And now i have xml payloads in console, but noy in log file.
UPDATE 2 Next lines added into log4j.properties
log4j.logger.org.apache.cxf.interceptor.LoggingOutInterceptor=TRACE, queryLog log4j.additivity.org.apache.cxf.interceptor.LoggingOutInterceptor=true
log4j.logger.org.apache.cxf.interceptor.LoggingInInterceptor=TRACE, queryLog log4j.additivity.org.apache.cxf.interceptor.LoggingInInterceptor=true
Query log log4j.appender.queryLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.queryLog.File=${log.dir}/queryLog.log log4j.appender.queryLog.layout=org.apache.log4j.PatternLayout log4j.appender.queryLog.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n log4j.appender.queryLog.DatePattern = '.'yyyy-MM-dd log4j.category.queryLogger=INFO, queryLog
queryLog is created but it is empty. =(
UPDATE 3
I add queryLog to the end of
log4j.rootLogger=INFO, stdout, defaultLog, errorlog
Now i have payloads in queryLog.log but the response looks as string. I'am trying to convert it in pretty xml.
Any idea how to convert into pretty xml response string in queryLog? :
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body> bla
bla bla bla