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:36

How do find your PHP error log on Linux:

eric@dev /var $ sudo updatedb
[sudo] password for eric:
eric@dev /var $ sudo locate error_log

/var/log/httpd/error_log

Another equivalent way:

eric@dev /home/eric $ sudo find / -name "error_log" 2>/dev/null

/var/log/httpd/error_log
查看更多
梦该遗忘
3楼-- · 2018-12-31 05:37

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

查看更多
与君花间醉酒
4楼-- · 2018-12-31 05:40

If You use php5-fpm log default should be under

/var/log/php5-fpm.log
查看更多
还给你的自由
5楼-- · 2018-12-31 05:41

It can also be /var/log/apache2/error.log if you are in google compute engine.

And you can view tail like this:

tail -f /var/log/apache2/error.log
查看更多
余生无你
6楼-- · 2018-12-31 05:41

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

查看更多
浮光初槿花落
7楼-- · 2018-12-31 05:41
  1. you can go in File Manager check logs folder.
  2. check Log file in public_html folder.
  3. check "php phpinfo()" file where log store.
查看更多
登录 后发表回答