MessageLogging policy vs backend api logging

Just want to hear what is the best practice or people usually do for logging, if my backend API already has logging in application code (say to Cloud Logging), is it still good idea to use MessageLogging policy? Should I use both logging or use just one of them? I understand that one can config MessageLogging to send the log to Cloud Logging, therefore I am bit concern if I do that then logs will be duplicated.

Anthony

0 1 142
1 REPLY 1

Hi Anthony,

I guess it depends on what you want to log, API traffic through Apigee or backend API traffic or both. I suggest you do both and configure that in Apigee.

You can use the Message Logging policy in Apigee X to log directly to Cloud Logging. You can configure logging for different levels of information (e.g. INFO, DEBUG). For example, INFO would just give you minimal log data, whereas DEBUG would include request and response payload information for both the API request and response in Apigee proxy and the backend API. You can also use a KVM to control the level, so you can turn on DEBUG level for awhile and then reset to INFO using Apigee API.

To achieve this, the general best practice is to capture logging information at each of the flow hook locations  and log once in PostClientFlow. You can use a Shared Flow and Flow Hook to capture the information so each proxy doesn't need to do that, but you will need to add the Message Logging policy in the PostClientFlow of each proxy (FYI - there's a feature request for a PostClientFlow Hook).

Hope that helps!