Я написал специальный класс для этого:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class CommonException extends Exception {
private $logFile = "../log/commonEx.log";
private $log = Array();
public $code = "";
public function __construct($message = null, $code = 0) {
$exLog['msg'] = $message;
$exLog['code'] = $code;
$this->code = $code;
$exLog['file'] = $this->getFile();
$exLog['line'] = $this->getLine();
$this->log = $exLog;
$this->_writeToLog($exLog);
sfLoader::loadHelpers('I18N');
}
public function display() {
return $this->log;
}
private function _writeToLog($exLog) {
error_log(implode("|", $exLog) . "\r\n", 3, $this->logFile);
}
}
В вашем try .. catch
блоке:
try {
// ...
} catch (Exception $e) {
$errMsg = new CommonException($e->getMessage(), $e->getCode());
// redirect to anywhere you want
}