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.
Why Enable Error Logging?
-
Detect syntax and runtime errors in your PHP scripts.
-
Monitor application behavior for debugging.
-
Improve security by keeping error details out of public view.
Steps to Enable PHP Error Logging
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
USERNAMEwith your Ruachost account username. -
Ensure the
logsdirectory exists and is writable.
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
Step 3: Verify Settings
-
Create a test script with an intentional error:
<?php echo $undefined_variable; ?> -
Run the script in your browser.
-
Check the log file (
php_errors.log) for the error entry.
Disabling Error Logging
To turn off error logging, modify the directive:
log_errors = Off
Best Practices
-
Store logs outside the public web root for security.
-
Rotate or clear logs regularly to prevent large files.
-
Use
display_errors = Offin production to avoid exposing sensitive details. -
Monitor logs frequently to catch issues early.