Logging SQL queries
• Magento2
Logging SQL queries in Magento2
In order to enable logging of sql queries in Magento2 you need to edit app/etc/di.xml
and
change the type for LoggerInterface
from Magento\Framework\DB\Logger\Quiet
to Magento\Framework\DB\Logger\File
.
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\File"/>
Append this at the end of the file to pass required arguments:
<type name="Magento\Framework\DB\Logger\File">
<arguments>
<argument name="logAllQueries" xsi:type="boolean">true</argument>
<argument name="debugFile" xsi:type="string">log/sql.log</argument>
</arguments>
</type>
Because I’m paranoid, I also executed a bin/magento cache:clean
afterwards and from now on all queries
should be logged into var/log/sql.log
.