API Message Logging - Start and End of a policy

Is there a way for me to log each and every start of every policies that my API had used without putting a message logging policy in each step?

Note that I needed to log the message into a specific log file for each step.

e.g.

Log Policy Start -> Assign Policy -> Log Policy End -> Log Policy Start -> Callout Policy -> Log Policy End

Solved Solved
0 7 1,383
1 ACCEPTED SOLUTION

Hi @Anil and @Tamilarasan

We decided to use apigee.metrics.policy.<policyName>.timeTaken to log specific policies that run on an API Proxy call.

Performance wise we do not need to do message logging or javascript policy with console.log each and every start or end of the policy (e.g. Assign or Callout Policy) as APIGEE already made the metrics available for us to check at the end of each API call. Thus we can create and gather message log data after the whole API execution and do the logging at a post client flow.

View solution in original post

7 REPLIES 7

@Harry Reynoso , Welcome to Apigee Community.

Great Question, Interested to know what is the use case behind logging each & every start, end of every policy. As you said, It's a performance kill to attach message log before & after every policy. More details will certainly help, Keep us posted.

Hi @Anil Sagar, the actual use case is for tracking purposes only. Without using the the APIGEE trace tool we should determine which policies were executed in a certain request.

@Harry Reynoso ,

You can set the debug sessions using APIs & get the info you are looking for using same debug session APIs. More details you can find here in our Management API Docs.

Hope it helps. Keep us posted if any.

@Anil Sagar

Thank you for the prompt response. I tried checking the link you had given but unfortunately creating a debug session will not be an option on our use case. What we needed is to create a log for each incoming request and log each policies it execute (start and end time of the policy execution). If we have an option to use a command like in java "system.out.print" which can be found on the APIGEE system log that can be an option as we can remove the use of message logging policy.

Not applicable

@Harry Reynoso You can use javascript to log message to splunk .

You can find corresponding tutorials here:http://dev.splunk.com/view/javascript-sdk/SP-CAAAEC9

You can find related information of how to log to splunk here :

https://community.apigee.com/articles/13298/log-messages-into-splunk.html

Hi @Anil and @Tamilarasan

We decided to use apigee.metrics.policy.<policyName>.timeTaken to log specific policies that run on an API Proxy call.

Performance wise we do not need to do message logging or javascript policy with console.log each and every start or end of the policy (e.g. Assign or Callout Policy) as APIGEE already made the metrics available for us to check at the end of each API call. Thus we can create and gather message log data after the whole API execution and do the logging at a post client flow.

Awesome, Thank you for sharing details with community. Keep us posted moving forward if any.