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"
  • -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"?>

<MessageLogging name="ML-LogPolicy">

<File>

<Message>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}"

"</Message>

<FileName>test2.log</FileName>

<FileRotationOptions rotateFileOnStartup="true">

<FileRotationType>TIME_SIZE</FileRotationType>

<MaxFileSizeInMB>10</MaxFileSizeInMB>

<MaxFilesToRetain>10</MaxFilesToRetain>

<!--RotationFrequency unit="minute">10</RotationFrequency-->

</FileRotationOptions>

</File>

<logLevel>ERROR</logLevel>

</MessageLogging>

0 1 223
1 REPLY 1

Not applicable

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 <FileRotationType>SIZE</FileRotationType> which will rotate the file only after the file size provided <MaxFileSizeInMB>10</MaxFileSizeInMB>

Hope it helps!!