如何在CodeIgniter(PHP)中进行错误记录 [英] How to do error logging in CodeIgniter (PHP)
本文介绍了如何在CodeIgniter(PHP)中进行错误记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些问题:
- 记录所有步骤错误?
- 如何创建错误日志文件?
- 如何将错误消息推送到日志文件(发生错误时)? li>
- 如何将该错误邮件发送到电子邮件地址?
解决方案
CodeIgniter内置了一些错误记录功能。
- 使您的 / application / logs 文件夹可写
- 在 /application/config/config.php 中设置
$ config ['log_threshold'] = 1; code>
或使用更高的数字,具体取决于您在日志中需要的详细信息 - 使用
log_message('error','Some变量不包含值');
- 要发送电子邮件,您需要扩展核心CI_Exceptions类方法
log_exceptions()
。您可以自己执行此操作,也可以使用此。关于扩展核心的更多信息 here
请参阅 http://www.codeigniter .com / user_guide / general / errors.html
I want error logging in PHP CodeIgniter. How do I enable error logging?
I have some questions:
- What are all the steps to log an error?
- How is an error log file created?
- How to push the error message into log file (whenever an error occurs)?
- How do you e-mail that error to an email address?
解决方案
CodeIgniter has some error logging functions built in.
- 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
See http://www.codeigniter.com/user_guide/general/errors.html
这篇关于如何在CodeIgniter(PHP)中进行错误记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文