Custom Microgateway access logs

nejra
New Member

Hi,

We are using Microgateway and would like to have access logs containing more information that default api logs on info level. Is it possible to alter existing api logs? This additional information we want to log is available for example in analytics plugin, so we could do the logging there. Another option is to have separate log file for this and another question is if this is doable through plugins and existing logging setup?

These are default logs per request:

1579016817500 info sourceRequest m=GET, u=/dummy, h=localhost:8080, r=::1:63762, i=1884d2b0-36e5-11ea-8759-8729f75470ae
1579016817554 info targetRequest m=GET, u=/api/dummy, h=localhost:8080, i=1884d2b0-36e5-11ea-8759-8729f75470ae
1579016818638 info targetResponse s=200, d=1139, i=1884d2b0-36e5-11ea-8759-8729f75470ae
1579016818645 info sourceResponse s=200, d=1146, i=1884d2b0-36e5-11ea-8759-8729f75470ae 

This is what we would like to have for source request (user=A, role=admin):

1579016817500 info sourceRequest m=GET, u=/dummy, h=localhost:8080, r=::1:63762, user=A, role=admin, i=1884d2b0-36e5-11ea-8759-8729f75470ae<br />
0 2 266
2 REPLIES 2

You'll have to write your own custom plugin for logging. See
https://community.apigee.com/questions/58357/logging-plugin-for-microgateway.html
for additional info and links to additional examples.

Thanks, I managed to create custom log via bunyan and analytics plugin... When I try to use custom plugin, issue is with oauth plugin that in case of error, returns error to client and skips all next plugins. Is there a way to make this work?