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

2018-12-31 05:06发布

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).

18条回答
步步皆殇っ
2楼-- · 2018-12-31 05:45

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 simply logs/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".

查看更多
春风洒进眼中
3楼-- · 2018-12-31 05:45

whereever you want it to, if you set it your function call: error_log($errorMessageforLog . "\n", 4, 'somePath/SomeFileName.som');

查看更多
一个人的天荒地老
4楼-- · 2018-12-31 05:46

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.

error_log = /var/log/php.errors

Other solution would be writing simple script which would list all error logs files from directory tree.

查看更多
还给你的自由
5楼-- · 2018-12-31 05:46
php --info | grep error

This is helpful. commented by sjas on question. so i included it as a answer.

查看更多
几人难应
6楼-- · 2018-12-31 05:49

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 your php.ini also and verify it by invoking phpinfo().

查看更多
流年柔荑漫光年
7楼-- · 2018-12-31 05:51

Try phpinfo() and check for "error_log"

查看更多
登录 后发表回答