Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Turn on PHP error logging

An error log is a diary where PHP writes every problem it finds. This guide shows how to turn it on and keep it tidy.

Web Hosting2 min read13 steps

Why use a log?

PHP is the language many websites run on. When something breaks, a visitor may see only a blank page. The log keeps the real message, with the file and line. You can read it later and fix the cause.

On a live site, do not show errors on screen. Visitors should not see your file paths. Write them to a log file instead.

Method 1: cPanel

  1. Log in to cPanel.
  2. Open MultiPHP INI Editor.
  3. Choose your domain.
  4. Set log_errors to On.
  5. Set display_errors to Off.
  6. Click Apply.
  7. To read the log, open the Errors page in cPanel, or look for an error_log file in your site folder.

Method 2: php.ini

  1. Open File Manager and go to your site folder.
  2. Open or create php.ini. Back it up first if it exists.
  3. Add these lines:
log_errors = On
display_errors = Off
error_reporting = E_ALL
error_log = /home/username/logs/php_errors.log

These lines turn on logging, hide errors from visitors, report all error types and choose the log file. Replace username with your account name, and make sure the logs folder exists.

Method 3: WordPress

Add this to wp-config.php, above the line "That's all, stop editing":

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Errors are saved to wp-content/debug.log. Turn WP_DEBUG off when you finish.

Keep the log from growing too big

Logs can grow large and eat your disk space.

  1. Check the file size every so often in File Manager.
  2. Download the log if you want to keep it, then delete or empty the file.
  3. On a VPS with root access, a tool called logrotate can do this for you. It rotates old logs on a schedule. Hostvento support can tell you what your plan offers.
Tip: Logs can show private paths. Do not share them in public places.

Quick recap

  • Turn on log_errors and turn off display_errors.
  • Use MultiPHP INI Editor, php.ini or wp-config.php.
  • Read the log to find the file and line.
  • Clean the log now and then.