MessageLogging Policy or new JavaScript file

I am trying to implement Apigee Logging to log several attributes such as Client IP, Total Processing Latency and other custom headers to be retrieved from request and response. They are categorized into BaseLog attributes, SysLog Attributes and AppLog Attributes, each of the latter written on top of the BaseLog. I would like to know what is the best way to log these - Would it be better to use MessageLogging Policy or to use custom JS code to extract and populate the variables?

Lastly, I have to send the logs to a Splunk server. How would one go about doing that ?

Any input would be helpful ! Thanks.

1 3 390
3 REPLIES 3

sidd-harth
Participant V

Extract and populate the variables using Javascript as each endpoint, but always use a MessageLogging policy in PostClientFlow to log to external systems.

Try it out and post your queries.

Not applicable

Different variables in apigee flows are having a life span of specific flows. When you want to log some values like that, use javascript policy in the flow and set those variables to context. And in the post client flow using message logging policy you can use the context variables to send to the splunk.

A good practice is to append what you want to log in a flow variable (eg: myLogMessage) using ExtractVariables and/or AssignMessage policies and the use a MessageLogging policy in the PostClientFlow using myLogMessage.