Exclude load balancer logs in Symfony 4.1

Hello i have a route like this in symfony app for health checks in digital ocean load balancer:

    * Status page. It is accessible only internally from within the network
    * @Route("/status", name="index_status", methods={"GET"})
    * @param Request $request
    * @return Response
   public function statusAction(Request $request): Response
       return new Response('Happy PDF printing');

And my monolog configuration looks like this:

            type: 'fingers_crossed'
            channels: ['!security']
            action_level: info
            excluded_http_codes: [403, 404, {200: ['^/ping(.+)', '^/status(.+)', '^/status?q=%2Fstatus', '^']}]
            handler: file
            type: stream
            level: debug
            path: "%kernel.logs_dir%/app.log"
            formatter: Monolog\Formatter\JsonFormatter
            include_stacktraces: true

However i can’t make monolog to not save logs about status requests from load balancer, they are made with request_uri like this Any idea if it’s possible to exclude them from symfony app?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I think that it might be because of the GET parameters in your status route: /status?q=%2Fstatus, maybe it is a good idea to try and change the route so that it does not require a get parameter, that way the excluded_http_codes rules should work.