TykTechnologies / tyk

Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Other
9.74k stars 1.09k forks source link

[TT-1530] Configurable and selective debugging messages in tyk's logs #2415

Open letzya opened 5 years ago

letzya commented 5 years ago

Do you want to request a feature or report a bug? Feature TT-1530

What is the current behaviour? The logs are very cluttered especially the gateway log. We constantly see lots of Active Nodes and pub-sub messages which are related to notifications from/to Redis. At the moment all these messages are making it hard for me to see debug messages generated by my own testing of the gateway.

What is the expected behavior? As a user of the gateway, I want to be able to test my APIs or call to endpoints in tyk and see the debug messages this activity generate. At the moment I have to dump the log to a file and filter out all the hundreds of notifications-related messages so I can't use tail -f.

If the current behaviour is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem ./tyk --debug and call an api without a key and find the relevant debug messages

My solution In tyk.conf add a field that lists all the prefixes we DO NOT want to to show up in the log. This way I do not have to see all the messages and I can gradually remove messages by type. For instance: tyk.conf: "avoid_log_prefix": { "Active Nodes": true, "pub-sub": true }

In the code, for log level DEBUG add another filter layer (in a similar manner to the log levels of warning, debug, info) that checks if the prefix is not in the avoid_log_prefix set before printing.

image

Which versions of Tyk affected by this issue? Did this work in previous versions of Tyk? 2.8.3+

letzya commented 5 years ago

@buger what do you think?

matiasinsaurralde commented 5 years ago

Would it be better to just use an array (assuming avoid_log_prefix is always for avoiding the messages), like:

"avoid_log_prefix":  ["Active Nodes", "pub-sub"]

Another suggestion, could we make it more general and allow regular expressions so that it becomes more extensible (not just prefixes)?

"avoid_logs": ["/^Active Nodes/", "host-check-mgr", "/something/"]

I like the idea!

letzya commented 5 years ago

Thanks @matiasinsaurralde!

  1. I like the regexp idea!!!

  2. About using true/false. The reason I add it was so I can toggle it and won't lose these "strings" so if I have "avoid_log_prefix": ["Active Nodes", "pub-sub", "host-check-mgr"] and I remove "host-check-mgr":"avoid_log_prefix": ["Active Nodes", "pub-sub"] and then I want to put back the "host checker", I'll have to remember the exact string , or look it up again. This way I retain my list and turn on/off whenever I want plus the logs that are not there are just enabled.

buger commented 5 years ago

Regarding DRL messages and all the spam, I actually never found it usable. So I propose just removing this log lines :)

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, please add comments to this ticket if you would like it to stay open. Thank you for your contributions.