YII日志以进行调试 [英] YII logging for debugging

查看:139
本文介绍了YII日志以进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多情况下, Xdebug 不适合调试,因为它涉及点击运行到特定的代码行。我想使用类似于 cakePHP 调试功能的开发人员输出一个类的特定属性的值到浏览器。



我使用 Yii框架,这是我的 yii log





'log'=> array(
'class'=>'CLogRouter',
'routes'=&array; array(
array 'class'=>'CFileLogRoute',
'levels'=>'trace,info,error,warning,vardump',
),
array '=>'CWebLogRoute',
'enabled'=> YII_DEBUG,
'levels'=>'error,warning,trace,log,vardump',
'showInFireBug' > true,
),
),
),

在我的一个定义的控制器,我把这段代码测试:

  Yii :: log(CallFromUserController ,'info','application'); 

但是我看不到这是印在firebug。我使用Chris的例子:


http://chris-backhouse.com/advanced-logging-in-yii/775



解决方案

我终于找到了一个解决方案:



在我的main.php我做到了:

 'log'=> array(
'class'=>'CLogRouter',
'routes'=&array; array(
array(
'class'=>'CFileLogRoute',
$ b //取消注释以显示网页上的日志消息
array($ b)
$ b'class'=>'CWebLogRoute',
'enabled'=> YII_DEBUG,
'levels'=>'错误,警告,跟踪,通知',
' '=>'application',
'showInFireBug'=> false,
),
),
),
/ pre>

在我的控制器中,我使用了以下代码:

  $ a = new array(1,2,3); 
Yii :: trace(CVarDumper :: dumpAsString($ a));

应用程序日志如下所示。


In many cases, Xdebug is not suitable for debugging as it involves clicks to run to a particular line of codes. I want to use something that is similar to cakePHP debug function for developers to output the value of a particular property of a class to the browser.

I am using Yii framework and this is my configuration for the yii log in the main.php:

'log'=>array(
    'class'=>'CLogRouter',
        'routes'=>array(
        array(
            'class'=>'CFileLogRoute',
            'levels'=>'trace, info, error, warning, vardump',
        ),
        array(
            'class'=>'CWebLogRoute',
                                'enabled' => YII_DEBUG,
            'levels'=>'error, warning, trace, log, vardump',
            'showInFireBug'=>true,
        ),
    ),
), 

In one of my defined controller i put this code to test:

Yii::log("CallFromUserController",'info', 'application');

However i don't see this being printed in the firebug. I used Chris's example:

http://chris-backhouse.com/advanced-logging-in-yii/775

解决方案

I finally managed to find out a solution:

In my main.php I did this:

'log' => array(
    'class' => 'CLogRouter',
    'routes' => array(
        array(
            'class' => 'CFileLogRoute',
            'levels' => 'trace, info, error, warning, vardump',
        ),
        // uncomment the following to show log messages on web pages
        array(
            'class' => 'CWebLogRoute',
            'enabled' => YII_DEBUG,
            'levels' => 'error, warning, trace, notice',
            'categories' => 'application',
            'showInFireBug' => false,
        ),
    ),
),

In my controller I used this code:

$a = new array(1,2,3);
Yii::trace(CVarDumper::dumpAsString($a));

The Application Log is shown below in every page.

这篇关于YII日志以进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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