Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Example—logging database activity

Example—logging database activity

To log database activity, use Magento\Framework\DB\LoggerInterface, which has two implementations:

To change the preference to \Magento\Framework\DB\Logger\File, edit your app/etc/di.xml.

First, change the default preference

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

to

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

After that, add the following block to configure file-based logging:

1
2
3
4
5
6
<type name="Magento\Framework\DB\Logger\File">
    <arguments>
        <argument name="logAllQueries" xsi:type="boolean">true</argument>
        <argument name="debugFile" xsi:type="string">log/db.log</argument>
    </arguments>
</type>
Updated