今天发现Yii框架的一款挺有意思的扩展:yii-debug-toolbar ,可以很直观地将本次请求的日志予以展现:
yii-debug-toolbar的图标:
蓝色的小瓢虫。
点击小瓢虫展开debug面板:

里面记录的内容还是蛮多的,当然你可以点开每个选项查看详情,比如SQL:

当我们想查看系统日志的时候就再也不用去翻runtime里的日志记录啦!
下面是下载地址和配制方法:
下载:http://www.yiiframework.com/extension/yii-debug-toolbar
完成后将文件拖至\project\protected\extensions目录下,解压到当前文件夹;
配置\project\protected\config\main.php
db配置添加enableProfiling与enableParamLogging参数:
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=yiidemo',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
'enableProfiling'=>true, //分析sql语句
'enableParamLogging'=>true, //日志中显示每次传参的参数
),
log配置,注释routes的class,替换为yii-debug-toolbar,配置ipFilters。
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
//'class'=>'CFileLogRoute',
'class'=>'ext.yii-debug-toolbar.YiiDebugToolbarRoute',
'levels'=>'error, warning',
'ipFilters'=>array('127.0.0.1','192.168.1.*'), //配置可以查看debug面板的ip
),
),
),
再去访问你的项目就会发现浏览器右侧出现了yii-debug-toolbar面板,当然,你可以点击右上角的蓝色小瓢虫隐藏它。
End.
文章来源于:
-----------------------额...你好~
介绍了一款Yii框架的扩展——yii-debug-toolbar,该扩展能够直观展示请求日志,包括SQL语句及其参数等详细信息,无需查阅runtime日志。文中还提供了安装及配置教程。

2329

被折叠的 条评论
为什么被折叠?



