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条)

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备