Hiding error logs?

I’m having some difficulty understanding Yii’s error logging mechanism. I’ve got the debug set to false in index.php:

defined(‘YII_DEBUG’) or define(‘YII_DEBUG’, false);

I’ve enabled the ‘log’ module in my config\main as per the below:

    'log' => array(

        'class' => 'CLogRouter',

        'routes' => array(


                'class' => 'CFileLogRoute',

                'levels' => 'error, warning',



                'class' => 'CWebLogRoute',




Normally, this works fine. However, when there’s an error in the program, the log is displayed at the bottom of the page on the production site, which is a security risk as it includes the database query information.

How do I disable the display of this log (while retaining a copy of the log on the server) on the production server?

Disable the CWebLogRoute if debug is off:





Awesome, thanks!

You’re welcome ;)

There’s a minor gotcha there since YII_DEBUG is always defined in yiibase like this

defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,false);

and this test, placed anywhere after the line in the index call to


will always show YII_DEBUG as defined, no matter that it is defined by define(‘YII_DEBUG’,false);

if (defined('YII_DEBUG'))

   echo "defined!";


   echo " NOT defined!";

If you don’t define YII_DEBUG, Yii will do it in YiiBase.php:

  defined('YII_DEBUG') or define('YII_DEBUG',false);

Test for true instead. This should work


(not tested)


Thanks Tommy. I was just pointing out the logical error and leaving the solution as an exercise.