Acquiring & Sending PHP Error Logs

Often it happens that due to some factors, such as server misconfiguration or large loads, the import may encounter a PHP error, which would immediately halt the import process and possibly leave some data corrupted. Errors of this kind occur in the background, and therefore will not be visible on screen, similarly to import errors; however, they are written to a different log: the PHP error log. For this reason, a support engineer may ask you to include this log with the description of your problem.

The location of this log depends on the configuration of the web server. In most cases the log file is called _debug.log_ and may be found in the content directory of your WordPress site which is wp-content, unless that is overridden by WP_CONTENT_DIR; this is true if the Debug Mode is enabled in WordPress. In short, the following configuration constants need to be set:

  • WP_DEBUGtrue – make sure errors are not suppressed;
  • WP_DEBUG_DISPLAYfalse – hide errors from the users of the website;
  • WP_DEBUG_LOGtrue – write the errors to log file.

If the above configuration is not present at the time of investigation, no messages will be written to log, and it may not exist at all. For this reason, after configuring WordPress in the way described above it is necessary to reproduce the problem. If you suspect or have been informed that a PHP error potentially occurs during import from a particular source, running that import again will cause the relevant entries to be written to the log file.

After the log has been populated it can be backed up, and normal configuration may be restored. It’s best to avoid leaving the debug mode on for too long to avoid making it unnecessarily large – “heavy” log files are harder to send, and take longer to analyse. Debug Mode is also not advisable for production environments.

If after putting in place the above configuration the error log cannot be found, then the location defined in your web server’s configuration needs to be checked. Many times, it is the root directory of your website, but may also be _/var/log/httpd/error_log_, _/var/log/apache2/error.log_, _/usr/local/apache/logs/error_log_ or any other directory, as defined by the error_log PHP directive. If the error log still cannot be found at these locations, or access to them is restricted, the only way to retrieve the log would be to contact your hosting service provider.

Finally, the error log, as all other logs, should be attached to your email as a file, instead of embedding it directly into the text of the email. This will improve readability of your email, helping us solve your case faster.

Still need help? Contact Us Contact Us