unsafe_where_true
unsafe_where_true

Reputation: 6310

php/yii logging: categories not working

in my controller:

private $log_category   = "application.event";
private $log_info           = "info";

then I log like this (in the same controller):

Yii::trace("actionIndex", $log_category);
Yii::log("saved",$log_info,$log_category);

but it doesn't work: the logs don't appear in the log file. Here's the config:

'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'error,warning,info,trace',
                    'categories' => 'application'
                ),
            ),

neither "*" nor "application.*" works; but if I remove the categories parameter altogether (or put it to empty), I get system messages in the log - this means the log file is being written and that somehow my categories are wrong.

How to define the category?

Upvotes: 0

Views: 1322

Answers (1)

jborch
jborch

Reputation: 1136

You missing a $this when calling your class properties:

Yii::trace("actionIndex", $this->log_category);
Yii::log("saved",$this->log_info,$this->log_category);

Upvotes: 3

Related Questions