大网数据广告活动
服务器运维问答

Error Log for Apache, PHP, and Codeigniter

· 52CE 我爱测

In our Apache access logs, we've noticed users occasionally getting a 500 error. It is likely a database query problem within our CodeIgniter code. We can't be sure how to fix it until we see the error. So, I'm trying to get the …

问题原文

原帖链接 · Christian · CC BY-SA 4.0

In our Apache access logs, we've noticed users occasionally getting a 500 error. It is likely a database query problem within our CodeIgniter code. We can't be sure how to fix it until we see the error. So, I'm trying to get the error printed to the error log and have been failing at that. Here's where I'm at:

  • Turned on error logging in Apache's php.ini file (/etc/php/7.2/apache2/php.ini) with the line: log_errors = On
  • Error reporting in CodeIgniter is set to: error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
  • The site's Apache vhosts config specifies an error log (/var/log/apache2/minans_error.log) which is getting populated with notices about IPs we've blocked in our .htaccess file, but not with 500 errors.
  • The error max length in php.ini has been set to 0 with the line: log_errors_max_len = 0
  • I forced log_errors on in CodeIgniter: ini_set('log_errors', 1);

  • I changed the permissions on the error log file to 666.

  • I forced the error log file in CodeIgniter with: ini_set('error_log', '/var/log/apache2/minans_error.log');

I'm hoping someone can tell me where I'm going wrong, suggest other things to try, or if I'm misunderstanding Apache's ability to log errors to point that out to me.

已采纳解答

原帖链接 · Christian · CC BY-SA 4.0

In testing I wrote some test code with a PHP error. When attempting to load the page a 500 error occurred and the PHP error was recorded to the error log.

We suspect, the 500 errors our users are getting is a database query error. This is being handled by CodeIgniter and not triggering Apache's error logging. In CodeIgniter's config.php file I set $config['log_threshold'] = 1. Now CodeIgniter it logging errors it captures to it's application/logs directory.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-06-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。