如何在CodeIgniter(PHP)中进行错误记录 [英] How to do error logging in CodeIgniter (PHP)

查看:147
本文介绍了如何在CodeIgniter(PHP)中进行错误记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要PHP CodeIgniter中的错误记录。如何启用错误日志记录?



我有一些问题:


  1. 记录所有步骤错误?

  2. 如何创建错误日志文件?

  3. 如何将错误消息推送到日志文件(发生错误时)? li>
  4. 如何将该错误邮件发送到电子邮件地址?


解决方案

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:

  1. What are all the steps to log an error?
  2. How is an error log file created?
  3. How to push the error message into log file (whenever an error occurs)?
  4. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆