Skip to content

Question: Would it be possible to log request and response in the same log entry? #2043

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

Open
bgalek opened this issue Mar 6, 2025 · 2 comments
Assignees

Comments

@bgalek
Copy link

bgalek commented Mar 6, 2025

Hi!
One of my teams asked if my team could develop
a logbook strategy that would log requests
and responses in the same log message.

Example:

>> INCOMING >> AFTER REQUEST  
Request: GET /api/endpoint?parameter=allegro-pl  
  Body: <empty body>  
Response: Status 200, took 5 ms  
  Body: {"works":true}  

I can think of some potential problems (but this library solves some) BUT I wanted to know your opinion as maintainers! Did you thought about such feature? Or maybe I missed that this feature is actually supported? :)

@bgalek
Copy link
Author

bgalek commented Mar 17, 2025

friendly ping :)

@kasmarian
Copy link
Member

Hey @bgalek, what you want to achieve is possible to do via a custom Sink implementation, that would write the log only when void write(Correlation correlation, HttpRequest, HttpResponse response) is called. See CommonsLogFormatSink as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants