Java 记录axis2 客户端请求和响应
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2524301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Log axis2 client requests and responses
提问by Manuel Darveau
I would like to log all requests/responses made by an axis2 client.
I tried to create a file called client-config.wsdd
as describer in http://code.google.com/support/bin/answer.py?hl=en&answer=15137but without success (I don't get a log file).
我想记录axis2 客户端发出的所有请求/响应。我试图client-config.wsdd
在http://code.google.com/support/bin/answer.py?hl=zh-CN&answer=15137 中创建一个称为描述器的文件,但没有成功(我没有得到日志文件)。
Requests are made over https and I am not sure if it matters. I tried
请求是通过 https 提出的,我不确定这是否重要。我试过
<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
and
和
<transport name="https" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
without success.
没有成功。
采纳答案by Sankar K S
For Axis2-client side logging for SOAP messages, just use the following JVM arguments while running your standalone client or include this VM args in your Appln. Server start script,
对于 SOAP 消息的 Axis2 客户端日志记录,只需在运行独立客户端时使用以下 JVM 参数或将此 VM 参数包含在您的 Appln 中。服务器启动脚本,
JAVA_OPTS=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.httpclient.wire=debug -Dorg.apache.commons.logging.simplelog.log.org.apache.commons.httpclient=debug
C:\java %JAVA_OPTS% YourClientAppln.java
C:\java %JAVA_OPTS% YourClientAppln.java
Cheers, Sankar
干杯,桑卡尔
回答by Mark O'Connor
I normally just log the body of the SOAP message, passed to my service class.
我通常只记录传递给我的服务类的 SOAP 消息的正文。
public OMElement myOperation(OMElement request) throws AxisFault {
log.debug("Request: {}", request);
..
log.debug("Response: {}", response);
return response
}
Low tech but works for me :-)
技术含量低,但对我有用:-)
回答by Quartz
I know it's a bit verbose, but here's how we solved it:
我知道这有点冗长,但我们是这样解决的:
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
OMElement requestElement = request.getOMElement(RegisterIntegrationAgent.MY_QNAME, factory);
LOGGER.debug(requestElement);
回答by Buminda
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.httpclient.wire=debug -Dorg.apache.commons.logging.simplelog.log.org.apache.commons.httpclient=debug
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.httpclient .wire=debug -Dorg.apache.commons.logging.simplelog.log.org.apache.commons.httpclient=debug
This worked
这有效
回答by Abdul Gafoor
If you add the below lines to your log4j.properties file, you will need not to pass any VM or JVM parameters.
如果将以下几行添加到 log4j.properties 文件中,则不需要传递任何 VM 或 JVM 参数。
#Axis2
log4j.appender.AxisLogFile=org.apache.log4j.RollingFileAppender
log4j.appender.AxisLogFile.File=${catalina.base}/logs/Axis-client.log
log4j.appender.AxisLogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.AxisLogFile.layout.ConversionPattern=%d{ISO8601} [%X{UUID}] %5p %t %c{1} - %m%n
log4j.logger.httpclient.wire=DEBUG,AxisLogFile