Advertisement
Advertisement


Where does PHP store the error log? (php5, apache, fastcgi, cpanel)


Question

I am on shared hosting and have Cpanel, Apache, PHP is run by fastcgi. Where does PHP store the error log?

Is there any other way I can find the error log on shared hosting environment instead of having to go through entire site structure to look for error_log files?

I have access to the php.ini (I am using PHP version 5.2.16).

2015/08/24
1
400
8/24/2015 9:33:49 AM

Accepted Answer

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(); ?>
2019/10/22
320
10/22/2019 12:52:39 PM

Try phpinfo() and check for "error_log"

2011/02/26

Linux

php --info | grep error 

The terminal will output the error log location.

Windows

php --info | findstr /r /c:"error_log"

The command prompt will output the error log location

To set the log location

Open your php.ini and add the following line:

error_log = /log/myCustomLog.log

Thanks @chelmertez, @Boom for these (comments on the question).

2017/09/01

On a LAMP environment the php errors are default directed to this below file.

/var/log/httpd/error_log

All access logs come under:

/var/log/httpd/access_log
2013/12/20

How do find your PHP error log on Linux:

[email protected] /var $ sudo updatedb
[sudo] password for eric:
[email protected] /var $ sudo locate error_log

/var/log/httpd/error_log

Another equivalent way:

[email protected] /home/eric $ sudo find / -name "error_log" 2>/dev/null

/var/log/httpd/error_log
2014/08/07

It appears that by default php does not log errors anywhere, the error_log key in php.ini is commented out in all the install's I've seen.

Generally I:

  1. look for php.ini files. locate php.ini.
  2. Search these files for the error_reporting value;

    Which should be set to whatever amalgamation of php log levels are enough for you.,

    Eg: E_ALL & ~E_DEPRECATED & ~E_STRICT

  3. Check the error_log value to make sure it points to an actual place and is not commented out.

    The default value doesn't give a full path, only a file name, I don't know where this path resolves to normally. Probably /var/log/.

2015/05/06

Source: https://stackoverflow.com/questions/5127838
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]