Yii::trace() Not Firing

New to Yii. Read every relevent post I could find, including Logging and the logging api doc. I cannot get the trace method to fire. 1) I know the app reaches that code because I get a json callback from the external app (using yii as a web service). Last update to application.log was an hour ago when i incorrectly used logVars


2014/01/21 18:37:26 [error] [php] Use of undefined constant logVars - assumed 'logVars' (/Applications/MAMP/htdocs/dashboard/protected/controllers/ApiController.php:93)

So I know I can reach it.

At the beginning of the called method I place


Yii::trace('[ApiController:actionCreate]');

And this is my log routing




        'log'=>array(

            'class'=>'CLogRouter',

            'routes'=>array(

                array(

                    'class'=>'CFileLogRoute',

                    'levels'=>'error, warning, log, trace, security',

                    'filter'=>array(

                        'class'=>'CLogFilter',

                        'logUser'=>true,

                        'logVars' =>array(array('_SERVER','REMOTE_ADDR'),

                            array('_SERVER', 'REDIRECT_URL'),

                            '_GET',

                            '_POST'

                        ),

                    ),

                ),

                array(

                    'class'=>'CEmailLogRoute',

                    'levels'=>'error, warning',

                    'emails'=>'mjstelly@gmail.com', //change for prod

                ),

            ),

        ),

When I examine application.log, there’s no recent logs. I want to log what happens in the method, because my $_POST values are not getting properly assigned, so the app inserts NULLS for everything. What am I doing wrong?

Check the YII_DEBUG constans.

The Yii::trace() is not logging if the YII_DEBUG is false or not set: github.com/yiisoft/yii/blob/1.1.14/framework/YiiBase.php#L451.

Try the Yii::log() instead of Yii::trace().

Found the error. Had two ‘log’ entries. Fixed that, now the log works. Now if I can only see why my app inserts nulls into the db. On to the next problem…

Thanks.

This can happen if your fields are not declared in validation rules array.

"This" meaning the null values? I have all the fields listed in the rules like this:




public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('opted_out, opted_in', 'numerical', 'integerOnly'=>true),

			array('last_visit, first_visit, this_visit, latitude, longitude, modified', 'numerical'),

			array('locale', 'length', 'max'=>5),

			array('device_maker, device_model', 'length', 'max'=>50),

			array('os_platform, os_version, model_type', 'length', 'max'=>10),

			array('user_id, last_visit, first_visit, locale, this_visit, latitude, longitude, device_maker, device_model, os_platform, os_version, opted_out, opted_in, modified, model_type', 'safe'),

		);

	}

So, I don’t think that is the problem. But I’m new to yii and have no idea if this is correct. Yii built this object.