YII logging for debugging

前端 未结 3 1405
无人共我
无人共我 2021-02-09 08:00

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 cak

3条回答
  •  无人共我
    2021-02-09 08:49

    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.

提交回复
热议问题