Skip to content

Enabling PHP error logging

PHP error logging helps you identify and troubleshoot issues in your scripts. On ruachost.com, you can configure error logging using the php.ini file or .user.ini depending on your hosting environment.

  • Detect syntax and runtime errors in your PHP scripts.
  • Monitor application behavior for debugging.
  • Improve security by keeping error details out of public view.

Step 1: Create or Edit a Custom php.ini File

Section titled “Step 1: Create or Edit a Custom php.ini File”

Add the following directives:

log_errors = On
error_log = /home/USERNAME/logs/php_errors.log
  • Replace USERNAME with your Ruachost account username.
  • Ensure the logs directory exists and is writable.

Step 2: Using .user.ini (Alternative Method)

Section titled “Step 2: Using .user.ini (Alternative Method)”

If your hosting environment supports .user.ini, add:

log_errors = On
error_log = /home/USERNAME/logs/php_errors.log
  1. Create a test script with an intentional error:

    <?php
    echo $undefined_variable;
    ?>
  2. Run the script in your browser.

  3. Check the log file (php_errors.log) for the error entry.

To turn off error logging, modify the directive:

log_errors = Off
  • Store logs outside the public web root for security.
  • Rotate or clear logs regularly to prevent large files.
  • Use display_errors = Off in production to avoid exposing sensitive details.
  • Monitor logs frequently to catch issues early.