Ismail Marmoush
Ismail Marmoush

Reputation: 13600

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

Upvotes: 5

Views: 13135

Answers (2)

gSorry
gSorry

Reputation: 1274

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.

Upvotes: 8

Otar
Otar

Reputation: 2591

I was in a similar trouble with YII logger. Strange but I was kind of messing with parameter order.

This works for me:

<?php

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

Upvotes: 5

Related Questions