Yii Framework Forum: SQL logging - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

SQL logging Rate Topic: -----

#1 User is offline   KJedi 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 381
  • Joined: 19-October 08
  • Location:Nikolaev, Ukraine (Europe)

Posted 27 November 2008 - 12:44 PM

Is it possible to log queries Yii creates and excecutes? I'm interested in this to optimize DB best for them.
Very helpful would be logging the class name, where this query is initiated.
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 27 November 2008 - 01:12 PM

Yes, every SQL being executed or queried is logged. You just need to configure some log route to dump the logged messages out. See http://www.yiiframew.../topics.logging


0

#3 User is offline   KJedi 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 381
  • Joined: 19-October 08
  • Location:Nikolaev, Ukraine (Europe)

Posted 28 November 2008 - 05:50 AM

Thanks, I read that and tried the following:
'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'',
                    'categories'=>'system.*',
                    'logPath' => '/home/konstantin/testdrive/',
                ),
            ),
        ),

But nothing appears in the directory I specified :(
What I'm doing wrong?
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 28 November 2008 - 06:55 AM

Did you specify 'log' component in 'preload' property of app?
0

#5 User is offline   KJedi 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 381
  • Joined: 19-October 08
  • Location:Nikolaev, Ukraine (Europe)

Posted 28 November 2008 - 07:32 AM

Here is a whole config. Where is preload section?
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Every Style',

// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),

// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to set up database
'db'=>array(
// 'connectionString'=>'mysql:host=localhost;dbname=everystyle',
'username'=>'*******',
'password'=>'*******'
),
'authManager' => array(
'class' => 'CDbAuthManager',
'connectionID' => 'db',
),
'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'',
                    'categories'=>'system.*',
                    'logPath' => '/home/konstantin/testdrive/',
                ),
            ),
        ),

),
);

0

#6 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 28 November 2008 - 07:43 AM

You omitted:
    'preload'=>array('log'),

See:
http://www.yiiframew.../topics.logging
0

#7 User is offline   KJedi 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 381
  • Joined: 19-October 08
  • Location:Nikolaev, Ukraine (Europe)

Posted 28 November 2008 - 08:55 AM

yeah, thanks!
How could I miss that :(

Thanks a lot for help!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users