Symfony - suppress logging for specific endpoint

Viewed 122

I have specific endpoint where I put an empty response:

/**
 * @Route("/ping", name="ping")
 * @return JsonResponse
 */
public function gcpPingAction(): JsonResponse
{
    return $this->json([], Response::HTTP_OK);
}

In my log I get:

enter image description here

Is it possible to suppress somehow the logging of this endpoint that is hit? Just for that specific endpoint..

1 Answers

According to this, you should be able to do it like so.

monolog:
    handlers:
        main:
            # ...
            type: fingers_crossed
            handler: ...
            excluded_http_codes: [{ 200: ['^/ping$'] }]

Or like so

monolog:
    handlers:
        main:
            # ...
            type: fingers_crossed
            handler: ...
            excluded_http_codes:
                - urls:
                    - '^/ping$'

However, I did not test it.

Related