Building message structure in Message Logging policy ?

Not applicable

Hello,

I am using message logging policy to log details in a file . I am using following message structure for the same:

<?xml version="1.0" encoding="UTF-8" standalone="true"?> <MessageLogging name="Message-Logging" enabled="true" continueOnError="true" async="false">
 <DisplayName>Message Logging</DisplayName> <File>
<Message>This is a test message. Message id : {request.header.id:unknown}
 Timestamp:{system.timestamp}
 LogLevel:info
 TransactionId:{guuid}  AppName:{proxy.name} 
         Query parameters passed:{queryinfo.searchtext}  Header passed:{headerinfo.Accept} 
 ReqBody:{request.content}
 ResBody:{response.content}  Error:{error.content}
</Message>
<FileName>AuditAPI.log</FileName>
<FileRotationOptions rotateFileOnStartup="true"> <FileRotationType>SIZE</FileRotationType>
<MaxFileSizeInMB>10</MaxFileSizeInMB> <MaxFilesToRetain>10</MaxFilesToRetain>
</FileRotationOptions>
</File> </MessageLogging>

However, When i check in trace i dont see all the tags(variables) being populated. For example ,

ReqBody:{request.content}

ResBody:{response.content}

Error:{error.content}

Message id :{request.header.id:unknown}

But following variables are seen:

Timestamp:{system.timestamp}

LogLevel:info

TransactionId:{guuid}

AppName:{proxy.name}

Any idea what am i doing wrong?

0 2 309
2 REPLIES 2

  • Where are you attaching above policy ?
  • What is the request body ?
  • What is the response you are expecting from API ?
  • Do you see any errors ?

Message variables are contextual: they refer to different message types (request, response, or error) depending on the point within the API Proxy Flow in which they are called. Scope of variables is limited to depending on the point within the API Proxy Flow in which they are called. For example, error.content you see only in error flow. Above question is incomplete without more details to understand what exactly is the issue.

Not applicable

@Anil Sagar To answer your queries:

1>The above policy is attached in post client flow.

2> For this particular API there will not be request body as its a Get call. But other API's will have request body which will be a xml.

3>Response can be in xml/json, and i want to log the final response that is being sent to client.

4> No i dont see any errors in flow, however i passed wrong apikey to see "error.content" but no luck. I have done custom error handling for this but i can see "error .message " variable.