Request Stack does not deliver Information in Symfony 6.4.2

What could be causing the RequestStack to not deliver any information? I am running Shopware 6.5.8 on Symfony 6.4.2.

The following code (using file_put_contents) was used for debugging purposes:

public function onBeforeSendResponse(BeforeSendResponseEvent $event): void
{
    $request = $event->getRequest();
    $this->requestStack->push($request);

    $logMessage = 'Accessing URL: ' . $this->requestStack->getCurrentRequest() . PHP_EOL;          
    file_put_contents('/var/www/html/custom/plugin/CustomRouter/src/routedebug.txt', $logMessage, FILE_APPEND);

    // Rest of the code…
}

However, the routedebug.txt file is empty when I call an URL. What could be causing this issue? Is it related to server configuration? If yes, what might be the cause?