Answers:
正如Flyingmana向我解释的那样,感谢他。
$collection->load($printQuery = false, $logQuery = false)加载后记录或打印查询很重要,因为在该beforeLoad方法中可以完成很多事情。所以第一个答案:
Mage::log((string)$collection->getSelect(),null,'test.log',true);应该在load调用之后使用。
Mage::log($collection->getSelect()->__toString(), Zend_Log::DEBUG, 'test.log', true);编辑:
与其使用null(fallback to DEBUG)作为第二个参数,最好使用以下方法之一Zend_Log:
const EMERG   = 0;  // Emergency: system is unusable
const ALERT   = 1;  // Alert: action must be taken immediately
const CRIT    = 2;  // Critical: critical conditions
const ERR     = 3;  // Error: error conditions
const WARN    = 4;  // Warning: warning conditions
const NOTICE  = 5;  // Notice: normal but significant condition
const INFO    = 6;  // Informational: informational messages
const DEBUG   = 7;  // Debug: debug messages