禁用Codeigniter日志记录并允许本地PHP日志记录


Disable Codeigniter logging and allow native PHP logging

我正在运行Codeigniter 2.1.4,据我所知,Codeigniter正在拦截PHP错误消息并将其存储在/application/logs

我想禁用CodeIgniter日志记录,只允许使用本地PHP错误日志。

以前有人这样做过吗?

看一下主编码器index.php文件的顶部有不同的方式来定义环境,但你可以在索引页上定义它。你想要的是"生产"

    // comment this line out
    //define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
   // put in this line
    define('ENVIRONMENT', 'production');

您将在代码中看到,codeigniter也适应您的PHP版本。或者你可以直接在这段代码下面粘贴到

ini_set('display_errors', 0);

在显示错误和不显示错误之间切换的更快捷的方式。

= = = = 编辑

这篇文章是为了回复你的评论:

这是很好的信息,但不幸的是,CI似乎仍然是拦截"通知"级别的消息,并将它们输出到浏览器。

所以上面的指令控制错误消息是否发送到浏览器。否则,在代码编写器"记录"你的错误方面-你可以在application/config中关闭代码编写器记录,并做任何你想要的日志记录。

on/application/config.php检查$config['log_threshold'] = 0;

/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
|   0 = Disables logging, Error logging TURNED OFF
|   1 = Error Messages (including PHP errors)
|   2 = Debug Messages
|   3 = Informational Messages
|   4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 0;