I had some difficulty with this, because my Drupal installs are in-between php versions. I'm running PHP 8.1, but a lot of the modules that I use were written for PHP 7, and haven't been ported.
Anyway, adding the following line to your sites/default/settings.php in production has worked for me:
$config['system.logging']['error_level'] = 'none';