WSO2 ESB 代理日志中介属性
WSO2 ESB proxy Log mediator properties
我想记录(最好是关联)传入和传出的消息至少具有以下属性:
Date/Time
客户端地址(IP,名称可选)
方法
我可以使用以下方法使传入消息正常工作,但对于传出消息(返回客户端),它 returns null。
get-property('axis2', 'REMOTE_ADDR')
传入
[2016-01-18 13:18:46,339] INFO - LogMediator To: /services/UserService, WSAction: http://tempuri.org/UserService/Login, SOAPAction: http://tempuri.org/UserService/Login, MessageID: urn:uuid:3e4b7f91-cab0-4294-a013-3c837f6695a0, Direction: request, REMOTE_ADDR: = 172.xx.xx.xx
外向
[2016-01-18 13:18:46,505] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:8de88329-3968-4edc-8617-352fbcb5480b, Direction: response, REMOTE_ADDR: = null
随着 MessageId 的变化(我想可以预见),也无法关联传入和传出的消息。
是否有必要在入站端设置自定义 属性 来关联此?
AFAIK,您需要在 inSequence 上设置自定义 属性。
我在本地测试了这个,对于下面的代理,我能够为传入和传出消息获得 REMOTE_ADDR: = 172.xx.xx.xx。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="test"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="client-add" expression="get-property('axis2', 'REMOTE_ADDR')"/>
<log level="custom">
<property name="REMOTE_ADDR :" expression="get-property('client-add')"/>
</log>
<send>
<endpoint>
<address uri="http://www.mocky.io/v2/569cac78110000dc24ce7614"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
<log level="custom">
<property name="REMOTE_ADDR :" expression="get-property('client-add')"/>
</log>
</outSequence>
</target>
<description/>
</proxy>
有关在 Synapse 序列中检索 clientIP/Host 的更多信息,请参阅此 documentation。
有关如何从 WSO2 弹性负载均衡器的传出请求中获取客户端 IP 的更多信息,请参阅此 documentation
希望这些信息对您有所帮助。
谢谢
是的,您需要向 inSequence 添加自定义 属性 调解器以获取和保存传入请求的 IP 地址值。然后通过向 inSequence 和 outSequence 添加日志中介,您将能够看到 IP 地址也保留在传出消息中。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="oneProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="ip" expression="get-property('axis2', 'REMOTE_ADDR')"/>
<log level="full">
<property name="REMOTE_ADDR :" expression="get-property('ip')"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:8290/services/echo"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full">
<property name="REMOTE_ADDR :" expression="get-property('ip')"/>
</log>
<send/>
</outSequence>
</target>
<description/>
</proxy>
希望这对您有所帮助...
我想记录(最好是关联)传入和传出的消息至少具有以下属性: Date/Time 客户端地址(IP,名称可选) 方法
我可以使用以下方法使传入消息正常工作,但对于传出消息(返回客户端),它 returns null。
get-property('axis2', 'REMOTE_ADDR')
传入
[2016-01-18 13:18:46,339] INFO - LogMediator To: /services/UserService, WSAction: http://tempuri.org/UserService/Login, SOAPAction: http://tempuri.org/UserService/Login, MessageID: urn:uuid:3e4b7f91-cab0-4294-a013-3c837f6695a0, Direction: request, REMOTE_ADDR: = 172.xx.xx.xx
外向
[2016-01-18 13:18:46,505] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:8de88329-3968-4edc-8617-352fbcb5480b, Direction: response, REMOTE_ADDR: = null
随着 MessageId 的变化(我想可以预见),也无法关联传入和传出的消息。 是否有必要在入站端设置自定义 属性 来关联此?
AFAIK,您需要在 inSequence 上设置自定义 属性。 我在本地测试了这个,对于下面的代理,我能够为传入和传出消息获得 REMOTE_ADDR: = 172.xx.xx.xx。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="test"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="client-add" expression="get-property('axis2', 'REMOTE_ADDR')"/>
<log level="custom">
<property name="REMOTE_ADDR :" expression="get-property('client-add')"/>
</log>
<send>
<endpoint>
<address uri="http://www.mocky.io/v2/569cac78110000dc24ce7614"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
<log level="custom">
<property name="REMOTE_ADDR :" expression="get-property('client-add')"/>
</log>
</outSequence>
</target>
<description/>
</proxy>
有关在 Synapse 序列中检索 clientIP/Host 的更多信息,请参阅此 documentation。 有关如何从 WSO2 弹性负载均衡器的传出请求中获取客户端 IP 的更多信息,请参阅此 documentation
希望这些信息对您有所帮助。
谢谢
是的,您需要向 inSequence 添加自定义 属性 调解器以获取和保存传入请求的 IP 地址值。然后通过向 inSequence 和 outSequence 添加日志中介,您将能够看到 IP 地址也保留在传出消息中。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="oneProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="ip" expression="get-property('axis2', 'REMOTE_ADDR')"/>
<log level="full">
<property name="REMOTE_ADDR :" expression="get-property('ip')"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:8290/services/echo"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full">
<property name="REMOTE_ADDR :" expression="get-property('ip')"/>
</log>
<send/>
</outSequence>
</target>
<description/>
</proxy>
希望这对您有所帮助...