How can I disable logging for specific controllers or actions? I have actions that render either HTML or XML depending on controller parameters, and I want to get rid of the HTML that the logging generates at the bottom of my XML view. Is there a simple way to disable logging for specific controllers, actions, and/or views?
You may use such code to disable logging for all actions:
protected function beforeAction($action)
{
foreach (Yii::app()->log->routes as $route)
{
if ($route instanceof CWebLogRoute)
{
$route->enabled = false;
}
}
return true;
}
This code disables only CWebLogRoute because other logging methods doesn’t output anything.