Magento 2 enable MySQL query logging


– In app/etc/di.xml file locate

<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Quiet"/>

and change it to

<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\File"/>

– Pass constructor arguments like below. Check Magento\Framework\DB\Logger\File for more configuration options.

<type name="Magento\Framework\DB\Logger\File">
    <arguments>
        <argument name="logAllQueries" xsi:type="boolean">true</argument>
        <argument name="debugFile" xsi:type="string">query.log</argument>
    </arguments>
</type>

– Find log files under var directory

Gihan Kavinga

Technical lead at Netstarter PTY Ltd. Magento certified developer plus. Oracle certified professional Business Component Developer. Linux system admin.

2 Responses to “Magento 2 enable MySQL query logging”

  1. <path_to_url> piel

    I feel that is one of the most significant info for me. And i am satisfied reading your article. But want to statement on few general things, The site style is wonderful, the articles is in reality nice : D. Just right process, cheers

    Reply
  2. <path_to_url> Hassie

    Thanks for the info

    Reply

Leave a Reply

  • (will not be published)