【问题标题】:Debugging SQL queries in Yii. CFileLogRoute vs CWebLogRoute在 Yii 中调试 SQL 查询。 CFileLogRoute 与 CWebLogRoute
【发布时间】:2012-08-14 21:17:56
【问题描述】:

在网上广泛搜索后,我仍然无法弄清楚。 CWebLogRoute 不显示 SQL 调试信息,但 CFileLogRoute 显示。关于如何让 CWebLogRoute 工作的任何想法?谢谢!

这是我的配置文件:

'db'=>array(
    'connectionString' => 'mysql:host=localhost;dbname=myname',
    'emulatePrepare' => true,
    'username' => 'root',
    'password' => 'root',
    'charset' => 'utf8',
    'enableParamLogging'=>true,
    'enableProfiling'=>true,
),

'log'=>array(
    'class'=>'CLogRouter',
    'routes'=>array(
        array(
            'class'=>'CFileLogRoute',
            'levels'=>'error, warning, trace, info',
        ),
        array(
            'class'=>'CWebLogRoute',
            'levels'=>'error, warning, trace, info',
        ),
  )

【问题讨论】:

    标签: php sql debugging yii


    【解决方案1】:

    它至少显示了一些东西吗?它在我的本地工作正常。尝试将profile 添加到CWebLogRoute.levels。 顺便说一句,对于sql,我更喜欢CProfileLogRoute

    array(
        'class'=>'CProfileLogRoute',
        'enabled'=> YII_DEBUG,
    ),
    

    【讨论】:

      【解决方案2】:

      这并不能直接回答您的问题,但我发现 Yii 调试工具栏是我最近一直在做的工作的一个很棒的插件。它不仅会显示您正在运行的 SQL 语句(文字语句,而不是参数化版本),而且还会显示您确实经常需要的许多其他信息...

      您可以在这里获取:http://www.yiiframework.com/extension/yii-debug-toolbar/

      【讨论】:

      • 是给 Yii1 的? ;-)
      • 是的,它适用于 Yii 1.1,但从 Yii2 移植过来
      【解决方案3】:

      你的 yii 框架是什么版本的? 并设置级别''。

      'log'=>array(
              'class'=>'CLogRouter',
              'routes'=>array(
                  array(
                      'class'=>'CFileLogRoute',
                      // 'levels'=>'error, warning',
                  ),
                  // uncomment the following to show log messages on web pages
                  array( // configuration for the toolbar
                    'class'=>'XWebDebugRouter',
                    'config'=>'alignRight, opaque, runInDebug, fixedPos, collapsed, yamlStyle',
                    // 'levels'=>'error, warning, trace, profile, info',
                    'allowedIPs'=>array('127.0.0.1','::1','192.168.10.195','192\.168\.1[0-5]\.[0-9]{3}'),
                  ),
              ),
      
          ),
      

      【讨论】:

        猜你喜欢
        • 2011-10-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-26
        • 1970-01-01
        • 1970-01-01
        • 2011-01-15
        • 2012-10-28
        相关资源
        最近更新 更多