douying1119 2012-08-30 08:25
浏览 23
已采纳

在CakePHP系统中记录PHP致命错误

I need to log Fatal-errors of my website.

I normally check error.log and debug.log files for CakePHP errors.
But I found out that PHP related fatal errors aren't logged someplace.
It is also discussed in this thread.

I checked php.ini. IT has following lines:

log_errors = On
;error_log = filename

I don't have rights to change php.ini. I can ask admin to change this, but it seems like I need to ask him every time I need a change :) I also have concerns about performance. Whether logging errors can decrease performance or not?

So I find out that I can put following two lines inside my script to log errors and change folder or file name when I need.

ini_set("log_errors", 1);
ini_set("error_log", "/path/to/php-error.log");

So I want to know where to put this lines inside my codes? Should I put it inside AppController::beforeFilter ? Or is there a better place/solution in CakePHP 2 configuration?

  • 写回答

3条回答 默认 最新

  • doutao8774 2012-08-30 10:02
    关注

    this is an old thread. in the meantime with cake 2.x errors are all logged in productive mode - so also fatal errors.

    trigger one and check out your /tmp/logs/error.log

    but you can easily find that out looking at the core code: https://github.com/cakephp/cakephp/blob/master/lib/Cake/Error/ErrorHandler.php#L189

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable