Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to update ROUTER logs (nginx access log) from apigee policy?

Not applicable

How to update MESSAGE PROCESSOR logs using messageContext or executionContext object?

I am looking to update/cutomize message processor logs in apigee using messageContext or executionContext object. I find examples where they use javascript to send customized logs with the help of Splunk or third party logging system url. But i do not have access to my log server url, so have to update the logs through message context or execution context object. Can someone help me find a solution ?

Let me explain my requirement better.
I have my logs getting updated at

source = /opt/apigee/var/log/edge-router/nginx/marsh~Dev-US.9001_access_log


which is the message processor logs. I want to add more info to this log message from apigee. I see there is a message logging policy, but i am not sure how to use it to update my infomraiton to this log.

currently my log looks like this:

2018-06-27T08:52:03-05:00 usdf23v0488 10.23.119.33:62390 10.23.132.186:8998 0.179 - - 200 200 511 255 POST /proxy/m2-digital-broker-api-1.0.0-SNAPSHOT/auth/client/accesstoken HTTP/1.1 usdf23v0488-29638-119015-1 PostmanRuntime/7.1.1 10.23.132.186 usdf23v0488-29638-119015-1 10.23.119.33 - - - - - - green -1 /organizations/marsh/environments/Dev-US/apiproxies/M2-Digital-Broker-API-1.0.0-SNAPSHOT /proxy/m2-digital-broker-api-1.0.0-SNAPSHOT/auth/client/accesstoken dc-1 gateway green


I want to add more info to this log. Can you help me how to do this. Below is the message logging policy i used in my post flow

<MessageLogging name="Message-Logging-1">
  <DisplayName>Message Logging-1</DisplayName>
  <Syslog>
    <Message>HELLOHELLOHELLO</Message>
  </Syslog>
</MessageLogging>

@ Dino-at-google- can you please help me with this ?

Solved Solved
0 10 1,332
1 ACCEPTED SOLUTION

First, you said that

source = /opt/apigee/var/log/edge-router/nginx/marsh~Dev-US.9001_access_log

...is the message processor log. This is not true. This log file is for nginx. The router. it logs inbound API requests to the system.

Using the MessageLogging policy, you can log to a different, independent file.

This policy does not allow you to log to the nginx log file.

Also, to log to a file, you need to use the File element, not Syslog. Use the Syslog element when you have a Syslog endpoint.

Details are described in the fine documentation. The doc tells you exactly where the log file will appear. (Ignore the video there - i just looked and it's irrelevant to your question)

View solution in original post

10 REPLIES 10