logging and ajax requests

Hi all,

I am calling a controller action through an ajax call.

In my action there is a Yii::log call that should write something in the application log (which it does when calling the action via browser url).

So I found out that the log messages are written at the end of a cycle, which doe not not happen when calling the action through ajax

a I right ?

what would be a good workaround ?

thanks

This is by design because appending logging to ajax response may ruin your ajax behavior. You can set showInFireBug=true for the CWebRoute so that the logging output is displayed in FireBug console (for both normal and ajax responses)

thanks for the reply :)

but unless I'm mistaken all log messages are written at the end of the application cycle, when I use an action through ajax this app cycle does not fully complete so no log messages are written (even with firebug option)

juste tested it again and calling an action with a call to :

Yii::trace('test');

write 'test' in the firebug console with a normal call through browser url

but not through an ajax call

I would think that it would be very convenient to log to a file or to firebug even when requesting an action through ajax

but maybe I a missing something

thanks for your time

How did you deal with the ajax call? Are you calling exit() or something similar?

hi qiang,

here is the action that is called through ajax :



public function actionApprove() {


		 


              Yii::trace('test log message');





		if(Yii::app()->request->isPostRequest) {


			


			$comment = $this->loadComment();


			


			if($comment->approve()) {





				echo 'Comment approved';


				


			}





			


		}


	


     }


So I am not exiting

The full app cycle should be executed right ?

I tried to follow everything through a debugger and it is the case (all seems to be going on as in a normal cycle)

Do you get messages logged when doing ajax calls to actions ?

thanks a lot