Mautic throwing file permissions error, in particularly when apache restarts

Your software
My Mautic version is: 2.16.2
My PHP version is: PHP Version 7.2.24-1+ubuntu18.04.1+deb.sury.org+1

Your problem
My problem is: Mautic throwing file permissions error, in particularly when apache restarts. Apache restarting with sudo crontab.

These errors are showing in the log:
[Wed Jun 24 05:17:35.280614 2020] [php7:error] [pid 22287] [client 192.168.0.21:36038] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file “/var/www/mydomain/marketing/app/logs/mautic_prod-2020-06-24.php” could not be opened: failed to open stream: Permission denied in /var/www/mydomain/marketing/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/mydomain/marketing/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(107): Monolog\Handler\StreamHandler->write(Array)\n#1 /var/www/mydomain/marketing/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)\n#2 /var/www/mydomain/marketing/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#3 /var/www/mydomain/marketing/vendor/monolog/monolog/src/Monolog/Logger.php(518): Monolog\Logger->addRecord(400, ‘PHP Error: Unca…’, Array)\n#4 /var/www/mydomain/marketing/app/bundles/CoreBundle/ErrorHandler/ErrorHandler.php(427): Monolog\Logger->log(400, ‘PHP Error: Unca…’, in /var/www/mydomain/marketing/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107

Steps I have tried to fix the problem:
I have to set the whole folder to chown -R www-data:www-data