Logging database queries in Yii2

The original Yii had this nice feature where you could add

'enableParamLogging' => true,

'enableProfiling' => true 

to your database configuration. And then add


      'report' => 'callstack',

      'logFile' => 'profile.log',

      'logPath' => '/path/to/logs/'


to your log component configuration and you would get a nice comprehensive list of all SQL queries made by ActiveRecord.

I’ve searched and searched and not had any success figuring out a similar approach using Yii2. All I’ve found are solutions that force you to actually add logging calls in code. Is that all there is?

I can’t imagine others haven’t already run into this, but I can’t get the search function on the forum page to return any results- even for terms I know are in the forums…

Yii 2 logs queries as well. It’s of Logger::LEVEL_PROFILE, categories are ‘yii\db\Command::query’, ‘yii\db\Command::execute’. You can either configure logged using this info or use debug extension that supports viewing queries out of the box.