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).
The best way is to look in your httpd.conf file and see what the default is. It could also be overridden by your specific virtual host. I start by looking at
/etc/httpd/conf/httpd.conf
or/etc/apache2/httpd.conf
and search for error_log. It could be listed as either /var/log/httpd/error_log or/var/log/apache2/error_log
but it might also be listed as simplylogs/error_log
.In this case it is a relative path, which means it will be under
/etc/httpd/logs/error_log
. If you still can't find it check the bottom of your httpd.conf file and see where your virtual hosts are included. It might be in /etc/httpd/conf.d/<- as "other" or "extra". Your virtual host could override it then with ErrorLog "/path/to/error_log".whereever you want it to, if you set it your function call: error_log($errorMessageforLog . "\n", 4, 'somePath/SomeFileName.som');
You should use absolute path when setting error_log variable in your php.ini file, otherwise, error logs will be stored according to your relative path.
Other solution would be writing simple script which would list all error logs files from directory tree.
This is helpful. commented by sjas on question. so i included it as a answer.
If you have build Apache and PHP from source, then the error logs by default is generated at your
${Apache install dir}/logs/error_log
i.e generally/usr/local/apache2/logs/error_log
. Else, if you have installed it from repository, you will find it at/var/log/apache2/error_log
.You can set the path in yourphp.ini
also and verify it by invokingphpinfo()
.Try
phpinfo()
and check for "error_log"