Php 在Yii中调试SQL查询。CFileLogRoute vs CWebLogRoute
在网上广泛搜索之后,我仍然无法找到答案。CWebLogRoute不显示SQL调试信息,但CFileLogRoute显示。关于如何让CWebLogRoute工作有什么想法吗?谢谢 这是我的配置文件:Php 在Yii中调试SQL查询。CFileLogRoute vs CWebLogRoute,php,sql,debugging,yii,Php,Sql,Debugging,Yii,在网上广泛搜索之后,我仍然无法找到答案。CWebLogRoute不显示SQL调试信息,但CFileLogRoute显示。关于如何让CWebLogRoute工作有什么想法吗?谢谢 这是我的配置文件: 'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=myname', 'emulatePrepare' => true, 'username' => 'root', 'p
'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',
),
)
它至少显示了什么吗?它在我的本地电脑上运行良好。尝试将
profile
添加到CWebLogRoute.levels
中。
顺便说一句,对于sql
,我更喜欢CProfileLogRoute
:
array(
'class'=>'CProfileLogRoute',
'enabled'=> YII_DEBUG,
),
这并不能直接回答您的问题,但我发现Yii调试工具栏是我最近所做工作的一个极好的附加组件。它不仅会显示您正在运行的SQL语句(文字语句,而不是参数化版本),而且还会显示您实际上非常经常需要的许多其他信息
您可以在这里找到它:您的yii框架的版本是什么? 并将级别设置为“”
是给Yii1的吗?;-)是的,它是为YiI1.1设计的,但从Yii2移植而来
'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}'),
),
),
),