如何在Yii

时间:2015-08-12 18:12:41

标签: php logging yii

我有基于Yii的网站,我原来不知道的系统,它是从其他人那里找到的,并且那里有#34;错误500试图获得非财产-object"

我阅读了大量有关Yii中记录错误的文献,但似乎没有什么对我有用。这是我在main.php中记录的内容:

'log' => array(
    'class' => 'CLogRouter',
    'routes' => array(
        array(
            'class' => 'CFileLogRoute',
            'enabled' => true,
            'categories' => 'system.*',
            'levels'=>'error, warning, trace, profile, info',
            'showInFireBug' => true
        ),
    ),
),      
事实上,域名托管错误日志中没有错误(虽然它有其他站点的所有时间,但有麻烦)。 我尝试通过.htaccess启用php错误,我尝试在main.php中执行它 - 没有任何作用。

请帮忙 - 如何更详细地查看错误,最后将它们修复为Yii?..

1 个答案:

答案 0 :(得分:0)

在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,
      ),
   ),
),

编辑:

在这里你必须考虑Yii在主脚本结束后写日志,所以如果你使用die()命令终止你的脚本,你永远不会让Yii写下来。要避免此类问题,您应该使用Yii :: app() - > end()命令终止脚本。

查看更多: http://www.yiiframework.com/doc/guide/1.1/en/topics.logging#message-routing