http://bbs.phpchina.com/thread-274514-1-1.htmlphp
index.php ,这是CodeIgniter的入口文件,作开发是,都会设置一下
define('ENVIRONMENT', 'development');
用来区分线上和线下环境,可是在这里html
if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'development': error_reporting(E_ALL); break; case 'testing': case 'production': error_reporting(0); break; default: exit('The application environment is not set correctly.'); } }
CodeIgniter会判断一下,若是是production,它会将error_reporting设置为0,这会致使全部的错误都不记录php_error.log,可是error.log是咱们发现bug和解决问题的重要依据。
因此,根据咱们本身的经验,建议CodeIgniter用户将error_reporting(0),这段代码删掉,并将php.ini的
error_reporting=E_ALL&~E_NOTICE
display_errors = Off
若是你不能操做ini,那么就app
if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'development': error_reporting(E_ALL); break; case 'testing': case 'production': error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors','0'); break; default: exit('The application environment is not set correctly.'); } }
这样你的程序错误就不会暴漏给用户,而且会记录在php_error.log中,可是即便这样,依然会有一些错误会暴漏出来,这就涉及到CodeIgniter另外的坑。
原文连接
h5b.net/codeigniter-php_error-logcodeigniter