I am trying to use MessageLogging policy to Loggly. If I log response.content in the proxy PostFlow it works, but if I put the policy in the proxy PostClientFlow the response.content isn't available. Please help.
Thanks
Paul
Answer by Anil Sagar @ Google
·
Feb 25, 2016 at 05:33 AM
Good catch & Thank you for reporting same. I can able to reproduce issue. Seems like a bug.
Till the time issue is fixed, You can use a work around by setting up a custom variable using javascript & using same while message logging. I have verified same & it works.
In Javascript Policy, Post Flow Response,
context.setVariable('logResponse', context.getVariable("message.content"))
Message logging policy, In Post Client Flow Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <MessageLogging name="LogToSyslog"> <Syslog> <Message>[XXXXXXXXXXX@41058 tag="{organization.name}.{apiproxy.name}.{environment.name}"] Weather request for WOEID {logResponse}.</Message> <Host>logs-01.loggly.com</Host> <Port>514</Port> <Protocol>TCP</Protocol> </Syslog> </MessageLogging>
Results,
We will keep you posted on fix, till the time please use above workaround. Keep us posted if you have any queries.
Do we know by when the above issue ( message.content being blank in PostClientFlow) will be fixed? we are using On premise version.
Answer by paulmartin · Feb 25, 2016 at 01:57 PM
Your work around worked with the caveat that I had to place the following property in the HTTPTargetConnections or else 400 and 500 errors will enter the error flow and the logResponse variable won't be set.
<Properties>
<Property name="success.codes">1xx,2xx,3xx,4xx,5xx</Property>
</Properties>
@paulmartin , We can improve above solution using fault rules instead of changing success criteria which will affect analytics reports.
Execute same Javascript using default fault rule in target end point to set logResponse variable.
<DefaultFaultRule name="fault-rule"> <Step> <Name>JavaScript-3</Name> </Step> </DefaultFaultRule>
I like this approach better. Thanks for the improvement.
Answer by Karl Sponholz · Aug 01, 2018 at 05:24 PM
For me this doesn't work.
,Hi, for me this doesn't work. Has something changed ?
How to access Message Processor machines to check logs 4 Answers
How to customise file name in Post client flow in Message logging policy. 1 Answer
Is there any efficient way to identify list of skipped policies for logging purpose ? 3 Answers