How to disable PHP error logs

By default, PHP errors and warnings generated by your websites are logged in error_log files in the directory where your PHP files are located. The PHP error_log files can grow to a large size.

If you do not need the error_log file you can disable PHP error logging using one of the three ways listed below:

PHP Selector in cPanel — Recommended

  1. Log in to cPanel.
  2. Click Select PHP Version.
  3. Click Switch To PHP Options
  4. Set log_errors to Off
  5. Click Save

.htaccess

  1. Edit .htaccess in your public_html folder
  2. Enter the following code:1php_flag log_errors off
  3. Save the file.

php.ini

  1. Create a new file named php.ini in your public_html folder.
  2. Enter the following code:1log_errors = off
  3. Save the file.

Verify your changes

Create a phpinfo php page to check your settings are active.

Delete existing PHP error_log files

  1. View your webspace using FTP or cPanel File Manager
  2. Select your error_log file
  3. Delete


Leave a Reply