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

Possibility to log request and response in separate logs #303

Closed
julien-maurel opened this issue May 7, 2020 · 3 comments
Closed

Possibility to log request and response in separate logs #303

julien-maurel opened this issue May 7, 2020 · 3 comments
Labels

Comments

@julien-maurel
Copy link

Q A
Symfony version 4.4
Bundle version 8.1.0

Hi,
Perhaps it's already possible but I didn't find how : is it possible to logs request and response details in 2 separate logs?
Because when I activate logs on my client, I have only one logs after the response.
Thanks.

@gregurco
Copy link
Member

gregurco commented May 7, 2020

Hello @julien-maurel
Please check this PR: #289
Does it solve your problem?

@julien-maurel
Copy link
Author

Hi,
No, I tried this settings and I have only one log (after response) even if I set logging to REQUEST_AND_RESPONSE.
Waht I try is to have one log before request execution and one log after (with response).
Thanks

@gregurco
Copy link
Member

gregurco commented Jul 1, 2020

Hello

Sorry for late response. If the problem is still actual then you can find the solution here:

  1. create custom middleware similar with this one: https://github.com/8p/EightPointsGuzzleBundle/blob/master/src/Middleware/LogMiddleware.php
  2. inject in middleware 2 loggers (not one, as in exemple)
  3. Configure first logger to write in first log file and trigger this logger in request middleware section. In the response middleware section trigger the second logger, which should be configured to write to separate file.

Important to know here how to configure different symfony loggers and how guzzle middlewares work.

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

No branches or pull requests

2 participants