Yii不明白如何记录消息

Ism*_*ush 5 php logging yii

我按照本教程但仍然进入网页刷新,然后转到该文件仍然无法找到我发送的日志消息我在控制器中写了以下行:

Yii::log("Index Checkout",CLogger::LEVEL_ERROR);
Run Code Online (Sandbox Code Playgroud)

我的配置:

'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',
              ),
             */
            ),
Run Code Online (Sandbox Code Playgroud)

gSo*_*rry 8

写入日志的正确方法是:

Yii::log($message, $level, $category);
Run Code Online (Sandbox Code Playgroud)

但重点是$ category不应该是空的.

上面的示例工作因为消息是按类别编写的,然后类别不为空,但它写入空消息.它写类别所以它看起来像消息..但它不是.


Ota*_*tar 5

我和YII记录器有类似的麻烦.奇怪,但我有点搞乱参数顺序.

这对我有用:

<?php

Yii::log('', CLogger::LEVEL_ERROR, 'Message Here...');
Run Code Online (Sandbox Code Playgroud)

  • 它是`Yii :: log($ message,$ level,$ category);` (10认同)