Enabling MySQL Query Logging

Posted About 12 years ago. Visible to the public.

In /lib/Varien/Db/Adapter/Pdo/Mysql.php change this property to true:

/**
 * Write SQL debug data to file
 *
 * @var bool
 */
protected $_debug               = false;

To enable logging for queries slower than a certain time, alter this property:

/**
 * Minimum query duration time to be logged
 *
 * @var float
 */
protected $_logQueryTime        = 0.05;

To log all queries, set this property to true:

/**
 * Log all queries (ignored minimum query duration time)
 *
 * @var bool
 */
protected $_logAllQueries       = false;

Optionally, you can log the call stack, to do so change this property to true:

/**
 * Add to log call stack data (backtrace)
 *
 * @var bool
 */
protected $_logCallStack        = false;

To change to location of the log file, alter this property:

/**
 * Path to SQL debug data log
 *
 * @var string
 */
protected $_debugFile           = 'var/debug/pdo_mysql.log';
Mike Whitby
Last edit
Over 7 years ago
Mike Whitby
Keywords
database, debugging, profiling
Posted by Mike Whitby to Magento (2012-03-01 10:36)