0

In WSO2 ESB, I wish to print all properties set during the service chain in property mediators at the end of sequence in logs. Is there any convenient way of doing so without know name of the properties?

Thanks

1
  • please change your title to a question form
    – Cem Kaan
    Aug 26, 2020 at 10:48

2 Answers 2

4

There is simpler way, than implement custom class mediator. You can use Script mediator for that and print all the properties with values from message context using code like below. It is working on WSO2EI 6.6.0 and on WSO2ESB 4.9.0

<script language="js"><![CDATA[var keySet = mc.getPropertyKeySet();
        var i = 1;
        var it = keySet.iterator();       
       while(it.hasNext()){
         var prop = it.next();
         java.lang.System.out.println(i + ": " + prop + " = " + mc.getProperty(prop));
         i++;
    }]]></script>

Update: I discovered that, on linux system the System.out.println doesnt work well, so you can use mc.getServiceLog() method to get logger for printing the information

<script language="js"><![CDATA[
       var keySet = mc.getPropertyKeySet();
       var i = 1;
       var it = keySet.iterator();
       var log = "\n\r";
       while(it.hasNext()){
         var prop = it.next();
         log += i + ": " + prop + " = " + mc.getProperty(prop)+"\n\r";
         i++;
    }
    mc.getServiceLog().info(log);
]]></script>
1

I don't see a direct way of doing this. One work around I found is to write a custom class mediator where you can get the property keyset as part of the message context.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.