Disabling CWebLogRoute inside controller action.


I would like to disable CWebLogRoute inside any controller action.

For example, if the action is an Ajax call, do not print out the web logs.

I searched the forums and the only solution seems to involve looking through the entire LogRoutes array, which doesn’t seem very clean.

Is there any thing like:





I had the same problem. I put this method in my base controller class:


	 * Render JSON data for ajax

	 * If data is_bool then render json where key='result' and value=data

	 * @param mixed $data


	public function renderJSON($data)


		if (is_bool($data))


			$data = array('result' => $data);


		header("Content-type: application/json;charset=utf-8");

		echo CJSON::encode($data);

		foreach (Yii::app()->log->routes as $route)


			if ($route instanceof CWebLogRoute)


				$route->enabled = false;





Then in my controller action instead of $this->render I call $this->renderJSON($withMyData);

Hope this helps

I found this solution.

In config i use a key for array.




		'cweb' => array(







in my controller action