Nilesh Kumar
Nilesh Kumar

Reputation: 400

How to print YII Logger without Yii::app()->end

I am using YII 1.0 logger but i am not able to print YII logs without Yii::app()->end.

Below is my test program :

$test = 123;
if($test){
    Yii::log('Test', CLogger::LEVEL_INFO, "This is for testing");
}

Below is my configuration settings :

'log' => array(
                'class' => 'CLogRouter',
                'routes' => array(
                    array(
                        'class' => 'CFileLogRoute',   
                        'levels' => 'trace, info, error, warning, vardump',                      
                    ),
                    array(
                        'class' => 'CWebLogRoute',
                        'enabled' => YII_DEBUG,
                        'levels' => 'error, warning, trace, notice',
                        'categories' => 'application',
                        'showInFireBug' => true,
                    ),
                     array(
                        'class'=>'CFileLogRoute',
                        'logFile'=>'custom.log',
                        'categories'=>'custom.*',
                    ),
                ),            
            ),

Is there something wrong in my code ? Thanks in advance.

Upvotes: 0

Views: 135

Answers (2)

MKR
MKR

Reputation: 46

Messages can be logged using yii::log,

syntax:

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

example:

Yii::log("This is for testing","error","custom");

Upvotes: 1

Related Questions