简体   繁体   English

Yii不明白如何记录消息

[英]Yii don't understand how to log a message

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',
              ),
             */
            ),

Right way to write to log is: 写入日志的正确方法是:

Yii::log($message, $level, $category);

But point is that $category should not be empty . 但重点是$ category不应该是空的

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. 它写类别所以它看起来像消息..但它不是。

I was in a similar trouble with YII logger. 我和YII记录器有类似的麻烦。 Strange but I was kind of messing with parameter order. 奇怪,但我有点搞乱参数顺序。

This works for me: 这对我有用:

<?php

Yii::log('', CLogger::LEVEL_ERROR, 'Message Here...');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM