How to Find Error Log Files for PHP

Where does PHP store the error log? (PHP 5, Apache, FastCGI, and cPanel)

PHP stores error logs in /var/log/apache2 if PHP is an apache2 module.
Shared hosts are often storing log files in your root directory /log subfolder.
But...if you have access to a php.ini file you can do this:

error_log = /var/log/php-scripts.log

According to rinogo's comment: If you're using cPanel, the master log file you're probably looking for is stored (by default) at

/usr/local/apache/logs/error_log

If all else fails you can check the location of the log file using

<?php phpinfo(); ?>

Find out the error_log's path

An internal server error has often something to do with Apache and /var/log/httpd/ is the error log file of Apache, so I think you are in the right file.


The error path is set in php.ini. To get the path use ini_get():

<?php
$errorPath = ini_get('error_log');
?>

Can't get PHP errors to go to a log file (other than the Apache log)

It had to do with ownership. One or the other has worked [for reasons that are not clear to me]:

chown www-data:www-data /var/log/php_error.log

chown same-user-as-www-home:same-user-as-web-home /var/log/php_error.log

Also, the following has made a difference:

chmod 664 /var/log/php_error.log

[as opposed to chmod 644...again for reasons that are not clear to me]

Where are my error log files?

The documentation for MAMP states:

4.5 Where can I find the log files?

All log files are stored in: /Applications/MAMP/logs/

What is the PHP built-in server error log location?

The built-in webserver doesn't log anywhere by default, so you need to provide a php.ini for it to customise this. For example, if you created a file called php.ini with this content:

error_log = /Users/me/test.log
log_errors = on
date.timezone = UTC

Then you can start PHP's built-in webserver like this:

php -S 127.0.0.1:8080 -c php.ini

And error_log() calls will be logged to the file you've specified.



Related Topics



Leave a reply



Submit