No output when log, only when error exist.

hi all!

I am using this config:


'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning, trace, info,debug',

					'enabled'=> true,

				  	'categories'=>'system.services.*',

					'logFile'=>'services.log',

					'logPath'=>'protected/log',

					'maxFileSize'=>1024,

					'maxLogFiles'=>10,							

				),

			),

In my controller:


Yii::log("foo", "error","system.services.KitController");

My app is in debug mode, and only log when error exist.

Thanks in advance.

Any hint?

Not sure I have the answer, but I have some questions:

  1. Why are you explicitly passing in the value "error" to the Yii::log() function?

    The default value for level is "info". All of your log messages will

    have the "error" level if this is how you consistently call the log() function.

  2. In your config file, why do you specify ‘categories’=>‘system.services.*’ ?

Here’s a config I use which works well:




'log'=>array(

   'class'=>'CLogRouter',

   'routes'=>array(

      // Log errors and warnings to : protected/runtime/error.txt

     array(

            'class'=>'CFileLogRoute',

            'levels'=>'error, warning',

            'logFile'=>'error.txt',

            ),

										

     // Log info and trace messages : protected/runtime/debug.txt

     // Do NOT include this in production

     array(

            'class'=>'CFileLogRoute',

            'levels'=>'info, trace',

            'logFile'=>'debug.txt',    

           ),      

           	

     // Since this is my DEBUG config, also display errors and warnings to the browser

     array(

          'class'=>'CWebLogRoute',

          'levels'=>'error, warning',

	  ),

     ),

),



On ‘info’ works!

but I want to log errors too, when i obtain an error response from my backend i want to log it as "error".

And why only log when a php error exist, i cant log as error.

Thanks Emily!

I just ran a test myself, using the same config file I included above:




Yii::log("TEST ERROR", "error");



Notice that I did NOT supply the 3rd argument to the function

The statement appeared in my error.txt file.

Can you :

  1. Try a simple log statement, like the one just shown

  2. Include your configuration for logging (if you modified it since first starting this post)

  3. Say what happens?