YII logging for debugging(用于调试的 YII 日志记录)
问题描述
在许多情况下,Xdebug
不适合调试,因为它涉及点击以运行特定的代码行.我想使用类似于 cakePHP
调试功能的东西,让开发人员将类的特定属性的值输出到浏览器.
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 cakePHP
debug function for developers to output the value of a particular property of a class to the browser.
我正在使用Yii框架
,这是我在main.php
中对yii log
的配置:
I am using Yii framework
and this is my configuration for the yii log
in the main.php
:
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'trace, info, error, warning, vardump',
),
array(
'class'=>'CWebLogRoute',
'enabled' => YII_DEBUG,
'levels'=>'error, warning, trace, log, vardump',
'showInFireBug'=>true,
),
),
),
在我定义的控制器之一中,我将此代码用于测试:
In one of my defined controller i put this code to test:
Yii::log("CallFromUserController",'info', 'application');
但是我没有看到这个被打印在萤火虫中.我用了克里斯的例子:
However i don't see this being printed in the firebug. I used Chris's example:
http://chris-backhouse.com/advanced-logging-in-yii/775
推荐答案
我终于找到了解决方案:
I finally managed to find out a solution:
在我的 main.php 中,我这样做了:
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.
这篇关于用于调试的 YII 日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用于调试的 YII 日志记录


- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01