Magento 2: Enable Database/MySQL Query Log

MySQL database query logging can be enabled/disabled from command line. This will help in debugging database queries. Enable database query logging The following CLI command enabled database/mysql query log: bin/magento dev:query-log:enable Flush cache bin/magento cache:flush After that, browse your Magento site. The database queries logs are saved in the file var/debug/db.log. Note: The database query … Read more

Magento 2: Writing Custom Log

In Magento 1, you could simply write your own custom log with the following code: Mage::log("Your Log Message", null, "your_log_file.log"); and it would be saved at MAGENTO_ROOT/var/log/your_log_file.log However, it’s not that simple and quite different in Magento 2. As Magento 2 uses dependency injection design pattern, you need to pass the logger instance through the … Read more

Magento: Writing Custom Log Message

To be able to write your custom log message, you have to enable logging from Magento Admin. To enable logging, go to Magento Admin Panel -> System -> Configuration -> Developer -> Log Settings -> Enabled = Yes Then in your code, you can write the following: Mage::log("Your Log Message"); You can check it at … Read more