Skip to content
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

Closed
AlexanderYastrebov opened this issue Jun 16, 2017 · 5 comments
Closed

How to log request/response based on response status #165

AlexanderYastrebov opened this issue Jun 16, 2017 · 5 comments

Comments

@AlexanderYastrebov
Copy link
Member

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.

@whiskeysierra
Copy link
Collaborator

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.)

@AlexanderYastrebov
Copy link
Member Author

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.

@whiskeysierra
Copy link
Collaborator

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.

@AlexanderYastrebov
Copy link
Member Author

But at least status and headers are there. Maybe JSON response could be accessible as well

@whiskeysierra
Copy link
Collaborator

whiskeysierra pushed a commit that referenced this issue Jun 27, 2017
…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
whiskeysierra pushed a commit that referenced this issue Jun 27, 2017
…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
whiskeysierra pushed a commit that referenced this issue Jun 29, 2017
…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
whiskeysierra pushed a commit that referenced this issue Jul 4, 2017
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants