-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to log request/response based on response status #165
Comments
With the current tools this could be achieved with some rather hacky formatter + logger implementations. From the top of my head I'd say a cleaner way would be to introduce markers for log messages generated by logbook: https://logging.apache.org/log4j/2.0/manual/filters.html. I could imagine to expose some properties of the captured messages. (Not 100% sure if this would work out of the box with the current design since we may not have those infos anymore when logging.) |
Maybe in such a case we may change the way we log: log request and response together later if logging is conditional on response properties. |
The problem is that the writer does not have enough information at hand at that point. When the response is to be logged it only receives a string, i.e. the formatted response. |
But at least status and headers are there. Maybe JSON response could be accessible as well |
See https://github.com/zalando/logbook/blob/master/logbook-api/src/main/java/org/zalando/logbook/HttpLogWriter.java#L13. We only have the raw strings at that point. |
…inspected. As a side effect a writer now has access to the request/response object in case any decisions need to be taken based on them. Fixes #165
…inspected. As a side effect a writer now has access to the request/response object in case any decisions need to be taken based on them. Fixes #165
…inspected. As a side effect a writer now has access to the request/response object in case any decisions need to be taken based on them. Fixes #165
…inspected. As a side effect a writer now has access to the request/response object in case any decisions need to be taken based on them. Fixes #165
With a high load it could be wasteful to log all request/responses.
It should be possible to log only failed request responses, e.g. where response status is not 20x.
The text was updated successfully, but these errors were encountered: