2

I am using WSO2 ESB 4.8.1. When i use log mediator, i want it to also log the proxy service name in which log mediator is being used. Is there any property defined in wso2 that i can use?

Problem:

In the following log mediator I am using "Server_IP" and "Server_HOST" property to pick up the Server IP and Server Host name. So is there any property from which i can pick up the service name.

Log Mediaator:

 <log level="full" separator="LogMediator" description="LoggerTemplate">
    <property name="ServerIP" expression="get-property('SERVER_IP')"/>
    <property name="ServerHost" expression="get-property('SERVER_HOST')"/>
    </log> 
Community
  • 1
  • 1
omer khalid
  • 855
  • 1
  • 12
  • 39

1 Answers1

7

Yes. Use the $ctx:proxy.name expression for your property mediator:

<log level="custom"> 
    <property name="proxyName" expression="$ctx:proxy.name"/>
</log>

Output:

[2015-02-06 06:24:07,161] INFO - LogMediator proxyName = vfsTest

Voicu
  • 16,921
  • 10
  • 60
  • 69
  • Thanks a lot. Could you also help me that if i want to pick up the Sequence Name in which i am using this Log Mediator. Can i do that ..? – omer khalid Feb 08 '15 at 12:37
  • @omerkhalid: I do not see a Synapse constant for that. The list is [here](https://synapse.apache.org/apidocs/constant-values.html#org.apache.synapse.SynapseConstants.PROXY_SERVICE). I have found multiple tutorials from WSO2 developers where they are hardcoding the sequence names in the `value` attribute of the property mediator, so there might not be a dynamic way of doing it. Example from one tutorial: ` ... `. – Voicu Feb 08 '15 at 15:30