PHP error log

From TNG_Wiki
Jump to: navigation, search

Not getting PHP errors on your site?

Your hosting service may have disabled php error returns to your browser.

You may be able to:

  • Update your php.ini to create a log file
  • Create a .user.ini file (supported by PHP 5.3 and later)
  • Install the Show PHP Error Log mod
  • Update the log location used by the Show PHP Error Log mod to point to where your PHP error log is located

Update php.ini

  • Create a log directory
  • FTP an empty txt fle to the log directory
  • Add a log entry in your site php.ini file that looks similar to the following, where you need to specify where the error log is written
  • Create log entry in your .user.ini file that looks similar to the following, where you need to specify where the error log is written
error_reporting = E_ALL | E_STRICT
log_errors = On
display_errors = Off
error_log = /home/account/www/log/php-errors.log

Create .user.ini

Or you could create a .user.ini file for the PHP error log overrides

Example of .user.ini file

Note that if you are modifying WampServer php.ini file you need to change the parameters individual where they occur in the file, or should add the above to the bottom of the php.ini and update the error log location
Note that on WampServer environments you will need to modify each and every PHP version php.ini file that you can switch to in WampServer. You probably should only modify php.ini files through the WampServer interface for each php version selected.
Note that on production sites you may want to put your PHP error log in the hosting service private area or in a folder that is not in the web root structure. If your web hosting service has a global account php.ini file, you may want to modify it to provide a default PHP error log location for any testing subdomain you might create.
Note that if you use the PHP Settings dialog on ICDSoft to enable the error log, the default PHP error log name and location is /home/account/private/php_error_log The PHP Settings dialog does not allow you to change the name nor the location.

Install log viewing mod

PHP error log location

The following is where you might find the PHP error log in different environments.

Note that in order to clear the log using the Show PHP Error Log mod, the write permissions for file must be granted to your web server.

Note also that when specifying the log location in the Edit Option you can use either an absolute path, or a relative path. A relative path is relative to your TNG installation and looks like


and an absolute path looks like


with the path starting at the top of the hierarchy and with a leading slash

For example ICDSoft's default PHP error log is coded as /home/account/private/php_error_log

Web hosting service

On your web site, the PHP error log will be where your hosting hosting service specifies in your account php.ini file if they make the log available. If the PHP error log is normally not available, you can override the options in the .user.ini file or in the php.ini file

Note that on your hosting service web site, you should consider putting your PHP error log in the hosting service's private area. You should consider using the .user.ini file since it will apply to all folders and subfolders, whereas the php.ini override file only applies to the folder it is specified in.

MacIntosh web server

On MacIntosh environments using the Apache webserver built in to Mac OS X, the PHP error log is probably at /private/var/log/apache2/error_log. To find it in the Finder, press Command-Shift-G and enter "/private/var/log/apache2/" to go to the folder that contains the error_log and the access_log.

This location is used whether you are using the Macintosh to access your site by "http://localhost/" or you have your domain name setup to be served by a Macintosh.

You can alter where the Macintosh saves the access_log and error_log files using statements in the httpd.conf file or the vhosts file if you have edited that. E.g. you can create separate access_log and error_log files for each domain if you're serving multiple domains.

When you have determined the location of the error_log and access_log files on the MacIntosh environment you can enter this path in the Mod configuration options.

MacIntosh MAMP Server

[I don't know anything about this - but I suspect that the access_log and error_log are not stored in the same locations as is used if you're using the builtin Apache webserver]

Windows WampServer

On localhost WampServer environments, the PHP error log likely at Drive letter:/wamp64/logs/php_error.log The location specified in the Edit options is relative to TNG, so it would be ../../logs/php_error.log

Note that in localhost WampServer environments, you can use the Edit Option to point to the Apache error log, which is likely at Drive letter:/wamp64/logs/apache_error.log and would be entered as ../../logs/apache2/error_log

Related Links

Ways to deal with php errors

Show PHP Error Log

Prolog Mod