Skip to content

[HttpClient] Control logging #50168

@ro0NL

Description

@ro0NL

Description

Hi,

Using HttpClient i found no way to;

  • log (masked) request bodies/headers for eg. urls matching X
  • log (masked) response bodies/headers eg. based on status code X and/or corresponding request
  • determine a log level based on response/request
  • determine the log channel (but i guess this is matter of manually calling CurlHttpClient::setLogger, but AFAIK it can't be wired using framework configuration)

Is there a way to achieve this currently?

At the moment we rely on https://github.com/php-http/logger-plugin, but i'd like to do it with Symfony HTTP Client, rather than having one HTTP client decorate another.

It should be noted this decoration approach (httplug => sfclient) creates double logs, somewhat by default. Luckily we only persist the specific channel in the outer client, not the http_client channel. However during console logs (-vv) things are super weird :)

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions