将数据添加到CakePHP 2的debug.log文件中

时间:2012-09-26 18:36:38

标签: php cakephp logging cakephp-2.0

在我的CakePHP 2.2应用程序中,我在debug.log文件中收到“通知”。我几乎每天都会收到这个警告,但我无法解决问题。所以我需要在debug.log中写一些额外的数据。但是当我发生这种“通知”时,我想写出这些数据。

例如我收到此通知:

2012-09-26 19:53:01 Notice: Notice (8):
 Trying to get property of non-object in
  [/var/www/vhosts/example.com/app/View/Tools/index.ctp, line 42]
Trace:
include - APP/View/Tools/index.ctp, line 42
View::_evaluate() - CORE/Cake/View/View.php, line 920
View::_render() - CORE/Cake/View/View.php, line 883
View::render() - CORE/Cake/View/View.php, line 475
Controller::render() - CORE/Cake/Controller/Controller.php, line 957
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 193
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 161
[main] - APP/webroot/index.php, line 96

我想在发出此通知时将所有会话变量添加到debug.log文件中 我怎么能这样做?
我可以更改lib/Cake/Log/Cakelog.php
我应该写什么?在哪里?

编辑:我粘贴了相关的代码段:

39       <?php if ($auth) { ?>
40        <form class="well" >
41
42            <?php if (isset($user->profile_url)) {
43            echo '<img src="'.$user->profile_url.'" width="48" height="48"/>';
44        } ?>
45
46            <strong><?php echo $user->screen_name; if (isset($user->name)) { echo " (" . $user->name . ")"; } ?></strong><br/>
47            <small><?php if (isset($user->description)) { echo $user->description; } ?> </small><br/>
48            <small><?php if (isset($user->url)) { echo $user->url; } ?> </small><br/>
49            <br/>

0 个答案:

没有答案