You can attach and configure a MessageLogging policy on your API to log custom messages to syslog server. such as (Splunk, Sumo Logic, and Loggly)
In this article will focus in Loggly you can create a free trail account (14 days ) and try it.
lets have a few steps :)
1) add PostClientFlow to your proxy
<PostClientFlow> <Request/> <Response> <Step> <Name>MLLoggingPolicy</Name> </Step> </Response> </PostClientFlow>
2) inject MessageLogging policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <MessageLogging async="false" continueOnError="false" enabled="true" name="MLLoggingPolicy"> <DisplayName>ML.LoggingPolicy</DisplayName> <Syslog> <Message variablePrefix="%" variableSuffix="#">[{loggly-token}@41058 tag="{apiproxy.name}"] { %message.content#, %message.headers.names# }</Message> <Host>logs-01.loggly.com</Host> <Port>514</Port> <FormatMessage>true</FormatMessage> </Syslog> </MessageLogging>
in above step you have to replace {loggly-token} with your own token
3) Viewing Logs in Loggly
References:
- https://docs.apigee.com/api-platform/reference/policies/message-logging-policy