1. Home
  2. Support
  3. Scripting
  4. Enabling PHP logging

Enabling PHP logging

This guide shows how to enable PHP error logging using your .htaccess file on an Apache web server.

Please Note: Log files to not automatically rotate. To prevent large files accumulating you should disable error logging once you have finished debugging.

1. Create a .htaccess file.

2. Stop PHP errors from displaying on your website by adding the following lines to your .htaccess file.

# Do not display PHP error messages
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off

3. Enable PHP error logging and specify your php_error.log by the following lines to your .htaccess file.

# enable PHP error logging
php_value error_reporting INSERT_VALUE_HERE
php_flag log_errors on
php_value error_log /hsphere/local/home/USERNAME/php_error_your_domain.log

VALUE
The value used defines the level or error reporting you require, for example:

  • -1 = ALL errors, not recommended but can be useful when used sparingly.
  • 30719 = Same as E_ALL, less info than -1
  • 30711 = E_ALL but not E_NOTICE
  • 30709 = E_ALL but not E_NOTICE or E_WARNING
  • 22517 = E_ALL but not E_NOTICE or E_WARNING or E_DEPRECATED

Please ensure that the path used in ‘php_value error_log’ is correct, you can find this from within your control panel under FTP/User Account > FTP User > Home Directory.

4. Create the php_error_your_domain.log file.

5. Depending on the PHP mode your site is running:

    • PHP libPHP mode you will need to give this file world writeable/777 permissions using your FTP client.
    • PHP FastCGI mode is recommend as you do not have to open additional permissions (FTP uploaded files will have 644 permissions by default).
Was this article helpful to you? 1 1

Last modified: 14/10/2019