Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii don't understand how to log a message

Tags:

php

logging

yii

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',
              ),
             */
            ),
like image 748
Ismail Marmoush Avatar asked Feb 08 '12 12:02

Ismail Marmoush


People also ask

How to log in yii?

yii\log\DbTarget − Stores log messages in a database. yii\log\FileTarget − Saves log messages in files. yii\log\EmailTarget − Sends log messages to predefined email addresses. yii\log\SyslogTarget − Saves log messages to syslog by calling the PHP function syslog().

Where yii store logs?

yii\log\DbTarget: stores log messages in a database table. yii\log\EmailTarget: sends log messages to pre-specified email addresses. yii\log\FileTarget: saves log messages in files.

How to check error log in yii?

If it's apache, you can find php errors in error_log. Then look into the yii runtime log. Yii can only catch runtime errors. For compile time/syntax errors are only reported in php error log, which I think is why you see blank screen.

How do I debug in yii?

Usage. Once the extension is installed, simply modify your application configuration as follows: return [ 'bootstrap' => ['debug'], 'modules' => [ 'debug' => [ 'class' => 'yii\debug\Module', // uncomment and adjust the following to add your IP if you are not connecting from localhost. //'allowedIPs' => ['127.0.


1 Answers

Right way to write to log is:

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

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.

like image 117
gSorry Avatar answered Sep 29 '22 19:09

gSorry