How to enable additional DB Profiler in magento2:
Magento2 is having one more additional DB profile option which will generate the mysql report as a CSV file.
1. Open app/etc/di.xml & find below line
<preference for=”Magento\Framework\DB\LoggerInterface” type=”Magento\Framework\DB\Logger\LoggerProxy”/>
Replace with below change
<preference for=”Magento\Framework\DB\LoggerInterface” type=”Magento\Framework\DB\Logger\File”/>
2. Enable debug log from the following class (We can also override & enable otherwise directly we can modify)
File Path: lib\internal\Magento\Framework\DB\Logger\File.php
It’s depend on the magento2 version what you are using. Here am using magento2.2. In case if the version
is magento2.0.x then refer file from Vendor folder. Modify, logAllQueries from false to true.
Sample Script:
public function __construct(
Filesystem $filesystem,
$debugFile = ‘debug/db.log’,
$logAllQueries = true,
$logQueryTime = 0.05,
$logCallStack = false
) {
3. Once done with above change, referesh the page & refer the debug log from root/var/debug/db.txt