How do I log ClientIp

Not applicable

We are trying to log clientIp by using the X-Forwarded-For header value in our messaging policy. Unfortunately it is always returning a null value. This is what we have in our policy

 <Message defaultVariableValue="null">
     "{system.time}"::clientIp="{request.header.X-Forwarded-For}"::user-agent=“{request.header.User-Agent}”::companyId="{companyid}"::userName="{username}"::requestType="{request.verb}"::requsetUri="{request.uri}"::JSESSIONID="{JSESSIONID}"::responseCode="{message.status.code}":: Response-RequestTimestamp="{system.timestamp}-{client.received.start.timestamp}"
  </Message>

. We know the header value exists because our backend server is logging the value of the remote IP

Could somebody please help me log this?

0 2 598
2 REPLIES 2

Not applicable

Hi @Abhinand Gokul,

In which flow you are using your message log ? I believe request.header.X-Forwarded-For will not be available if your policy is in response flow . What you could do is Assign request.header.X-Forwarded-For variable to another variable ( say clientIp) in the Proxy request preflow and then use it while message logging .

Hi @Abhinand Gokul, for incoming clients, you should use 'client.ip' variable. It has the originating client's IP.

What do you mean "our backend server is logging the value of the remote IP", is this in the response?

In that case, you need to use 'response.header.x-forwarded-for' in your message logging policy