Example—logging database activity
Example—logging database activity
To log database activity, use Magento\Framework\DB\LoggerInterface
, which has two implementations:
- Logs nothing (default):
Magento\Framework\DB\Logger\Quiet
- Logs to the Magento
var/log
directory:Magento\Framework\DB\Logger\File
To change the preference to \Magento\Framework\DB\Logger\File
, edit your app/etc/di.xml
.
First, change the default preference
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Quiet"/>
to
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\File"/>
After that, add the following block to configure file-based logging: