回到M1,您可以通过修改以下变量来记录慢速查询lib/Varien/Db/Adapter/Pdo/Mysql.php
:
/**
* Write SQL debug data to file
*
* @var bool
*/
protected $_debug = false;
/**
* Minimum query duration time to be logged
*
* @var unknown_type
*/
protected $_logQueryTime = 0.05;
/**
* Log all queries (ignored minimum query duration time)
*
* @var bool
*/
protected $_logAllQueries = false;
/**
* Add to log call stack data (backtrace)
*
* @var bool
*/
protected $_logCallStack = false;
/**
* Path to SQL debug data log
*
* @var string
*/
protected $_debugFile = 'var/debug/sql.txt';
所以我想知道如何在M2中做到这一点?我已经发现了一些有趣的东西,在lib/internal/Magento/Framework/DB/Logger/LoggerAbstract
和lib/internal/Magento/Framework/DB/Logger/File
,但我不是100%肯定该如何处理这个。