如何在 CodeIgniter (PHP) 中进行错误记录 [英] How to do error logging in CodeIgniter (PHP)
本文介绍了如何在 CodeIgniter (PHP) 中进行错误记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 PHP CodeIgniter 中记录错误.如何启用错误日志记录?
I want error logging in PHP CodeIgniter. How do I enable error logging?
我有一些问题:
- 记录错误的所有步骤是什么?
- 如何创建错误日志文件?
- 如何将错误消息推送到日志文件中(每当发生错误时)?
- 如何将该错误通过电子邮件发送到电子邮件地址?
推荐答案
CodeIgniter 内置了一些错误记录功能.
CodeIgniter has some error logging functions built in.
- 使您的 /application/logs 文件夹可写
- 在 /application/config/config.php 中设置
$config['log_threshold'] = 1;
或使用更高的数字,具体取决于关于您希望在日志中包含多少详细信息 - 使用
log_message('error', '某些变量不包含值.');
- 要发送电子邮件,您需要扩展核心 CI_Exceptions 类方法
log_exceptions()
.您可以自己执行此操作或使用this.有关扩展核心的更多信息此处
- Make your /application/logs folder writable
- In /application/config/config.php set
$config['log_threshold'] = 1;
or use a higher number, depending on how much detail you want in your logs - Use
log_message('error', 'Some variable did not contain a value.');
- To send an email you need to extend the core CI_Exceptions class method
log_exceptions()
. You can do this yourself or use this. More info on extending the core here
参见 http://www.codeigniter.com/user_guide/general/errors.html
这篇关于如何在 CodeIgniter (PHP) 中进行错误记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文