SQl-queries logging in production mode

Hi,

I need to logging SQL-queries into the separate file in production mode.

So, my config.php:




        'db'=>array(

            'connectionString' => 'mysql:host=<...>;dbname=<...>',

            'emulatePrepare' => true,

            'username' => '<...>',

            'password' => '<...>',

            'charset' => 'utf8',

            'schemaCachingDuration'=>3600, 

            'enableParamLogging'=>true,

            'enableProfiling'=>true,


        ),


        'log'=>array(

            'class'=>'CLogRouter',

            'routes'=>array(

                array(

                    // logging SQl queries: 

                    'class'=>'CFileLogRoute',

                    'levels'=>'trace',

                    'categories'=>'system.db.CDbCommand',

                    'LogPath' => '/var/log/apache/<...>',

                    'LogFile' => 'db.trace',

                    'maxFileSize' => 1024 * 100, //100 MB

                ),

                array(

                    'class'=>'CFileLogRoute',

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

                    'maxFileSize' => 1024 * 100, //100 MB

                ),

                array(

                    'class'=>'UserCEmailLogRoute',

                    'levels'=>'error',

                    'emails' => array(<...>),

                    'sentFrom' => '<...>',

                    'subject' => 'Error at <...>'

                    ),

                ),

        ),



But, it looks like logging does not work when I commenting YII_DEBUG definition in index.php:




// remove the following lines when in production mode

//defined('YII_DEBUG') or define('YII_DEBUG',true);



What’s wrong?

I just commented one line in framework’s file YiiBase.php…




    public static function trace($msg,$category='application')

    {

        //if(YII_DEBUG)

            self::log($msg,CLogger::LEVEL_TRACE,$category);

    }



… and now logging is works correctly.

But, I’m guessing that changing frameworks is very bad way.

Any other solutions?