Yii 不明白如何记录消息
我遵循了这个 教程 但我仍然去刷新网页,然后转到文件,但仍然找不到我发送的日志消息 我在控制器中编写了以下行:
Yii::log("Index Checkout",CLogger::LEVEL_ERROR);
以及我的配置:
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'logFile'=>'trace.log',
'class' => 'CFileLogRoute',
'levels' => 'error,info, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
I followed this tutorial but still I go to the webpage refresh, then go to the file and still I can't find the log message I sent
I wrote the following line in a controller:
Yii::log("Index Checkout",CLogger::LEVEL_ERROR);
And My configurations:
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'logFile'=>'trace.log',
'class' => 'CFileLogRoute',
'levels' => 'error,info, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
写入日志的正确方法是:
但要点是 $category 不应该为空。
上面的示例之所以有效,是因为消息被写入类别中,然后类别不为空,但它写入了空消息。它写入类别,因此看起来像消息..但事实并非如此。
Right way to write to log is:
But point is that $category should not be empty.
Example above works becouse message is written in category then category is not empty, but it writes empty message. It writes category so it looks like message.. but it isn't.
我在使用 YII logger 时也遇到了类似的麻烦。很奇怪,但我有点搞乱了参数顺序。
这对我有用:
I was in a similar trouble with YII logger. Strange but I was kind of messing with parameter order.
This works for me: