Message Logging - Advice

Hi,

I have a couple of questions wrt to the Message Logging Policy.

I created a policy that will log on Errors, but I am struggling to get any decent info out of the message logs. Below is the policy which I created so far.

So my issues I am getting is the following:

  • -If it is a 200 OK it gets logged even if I set the LogLevel to ERROR
  • -Not all failures get logged. (I want to log all failures (Errors))
  • -The only content that gets logged in my “MESSAGE” below is “message.status.code”
  • -How do I log the message associated to the Error. I have tried multiple variations from the following page: https://docs.apigee.com/api-platform/reference/variables-reference but most of them logs a blank value
  • -Is it possible to log information in multiple lines
  • -Is there recommended objects to log that will kind of substitute running a trace? So that we can troubleshoot after the fact.
  • -Will one transaction be logged per file or is it going to log multiple per files

Message Logging Policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Error Code: {message.status.code} || Error Content: {error.transport.message} || Error Message: {error.reason.phrase} || {request.header.x-api-key.values} || {request.header.content-type.values}"

"

test2.log

TIME_SIZE

10

10

ERROR

Hi Etienne,

I hope you are using message logging policy in the postclientflow where it should be invoked in every request.

For errors, you might can use below flow variables too :-

  • error.header.X-Apigee.fault-policy
  • error.header.X-Apigee.fault-flow

Other than this you can extract error code or description from target calls and assign the same to custom variables for logging purpose.

For File rotation, you can use SIZE which will rotate the file only after the file size provided 10

Hope it helps!!