Hi,
I want to log all mysql queries. I found the following file: lib/internal/Magento/Framework/DB/LoggerAbstract.php
I set in the constructor: $logAllQueries = true
However, I do not see any additional files in var/log
after logging into the backend.
Could you tell me how to check these queries?
In advance, thank you.
Hi @tommyJS ,
you should not need to use or change the LoggerAbstract
.
Magento relies on \Magento\Framework\DB\LoggerInterface
for logging and has two implementations out of the box: \Magento\Framework\DB\Logger\Quiet
(default one, logs nothing) and \Magento\Framework\DB\Logger\File
(really logs something).
To enable logging, change preference for Magento\Framework\DB\LoggerInterface
to \Magento\Framework\DB\Logger\File
in app/etc/di.xml
(search for Magento\Framework\DB\LoggerInterface
in the file - it should have preference to Quiet
, which you need to change):
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\File"/>
See also constructor of Magento\Framework\DB\Logger\File
to find what can be configured and what are default values. You can configure necessary values in the same di.xml
. For example,
<type name="Magento\Framework\DB\Logger\File">
<arguments>
<argument name="logAllQueries" xsi:type="boolean">true</argument>
<argument name="debugFile" xsi:type="string">my.log</argument>
</arguments>
</type>
Hi @buskamuza ,
thank you for the quick answer.
It works ;)
Most helpful comment
Hi @tommyJS ,
you should not need to use or change the
LoggerAbstract
.Magento relies on
\Magento\Framework\DB\LoggerInterface
for logging and has two implementations out of the box:\Magento\Framework\DB\Logger\Quiet
(default one, logs nothing) and\Magento\Framework\DB\Logger\File
(really logs something).To enable logging, change preference for
Magento\Framework\DB\LoggerInterface
to\Magento\Framework\DB\Logger\File
inapp/etc/di.xml
(search forMagento\Framework\DB\LoggerInterface
in the file - it should have preference toQuiet
, which you need to change):See also constructor of
Magento\Framework\DB\Logger\File
to find what can be configured and what are default values. You can configure necessary values in the samedi.xml
. For example,