[英]I can't get php errors to log to a custom log in CentOS 7.3 and PHP7
我在public_html
的php.ini中有
display_errors = on
error_reporting = E_ALL | E_STRICT
log_errors on
error_log /home/account/public_html/error.log
phpinfo
显示public_html
中的php.ini
文件正在加载。 error_log
文件具有755权限,并且与public_html
所有其他文件属于同一group:owner。
但是,当我强制执行php错误时,不会显示或记录任何错误。 错误记录在/usr/local/apache/logs/error_log
。 我已经重新启动了Apache。
有任何想法吗?
尝试更改:
log_errors on
error_log /home/account/public_html/error.log
至
log_errors = on
error_log = /home/account/public_html/error.log
接下来,在脚本顶部附近,执行以下操作:
echo php_ini_loaded_file(); // to make sure that you're editing the right php.ini
echo ini_get('log_errors'); // should be '1'
echo ini_get('error_log'); // should be path from php.ini
如果设置与您设置的设置不匹配(我假设您已重新启动Apache),请检查php.ini
的其余部分以及Apache VirtualHost配置,以获取可能会覆盖您的其他设置。
当您运行phpInfo()
,它有时会显示要加载的ini
文件的列表(不仅仅是基本的php.ini
。其中一个还可以包含替代项。
最后,如果这些都不起作用,则可以使用ini_set()
设置脚本错误记录。 请注意,如果该脚本本身有错误,则此设置可能没有机会生效,因此最好在与主脚本分开的脚本中进行设置并要求它
main.php
require_once('./init.php);
// ... your regular script
init.php
ini_set('log_errors', '1');
ini_set('error_log', '/path/to/errors.log');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.