YII日志进行调试

mad*_*adi 7 php cakephp yii

在许多情况下,Xdebug它不适合调试,因为它涉及到运行到特定代码行的点击.我想使用与cakePHP调试函数类似的东西,以便开发人员将类的特定属性的值输出到浏览器.

我使用的Yii framework,这是我的配置yii log中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,
        ),
    ),
), 
Run Code Online (Sandbox Code Playgroud)

在我定义的控制器之一中,我将此代码用于测试:

Yii::log("CallFromUserController",'info', 'application');
Run Code Online (Sandbox Code Playgroud)

但是,我不认为这是在萤火虫中打印出来的.我用克里斯的例子:

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

mad*_*adi 10

我终于设法找到了解决方案:

在我的main.php中我这样做了:

'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,
        ),
    ),
),
Run Code Online (Sandbox Code Playgroud)

在我的控制器中我使用了这段代码:

$a = new array(1,2,3);
Yii::trace(CVarDumper::dumpAsString($a));
Run Code Online (Sandbox Code Playgroud)

应用程序日志显示在下面的每个页面中.