Our blog

 

Magento Detailed Exception Log

I have never been a particular fan of PHP's standard stack trace - it tantalises you with a short snippet of info for each step of the trace that always seems to miss off the really useful bit of info.

I have done previous posts before on how to get a more detailed stack trace. If you want to have this in Magento you need to edit Mage.php (I currently don't know a way of overriding Mage.php) with this code (around line 724)

PHP:
  1. /**
  2.      * Write exception to log
  3.      *
  4.      * @param Exception $e
  5.      */
  6.     public static function logException(Exception $e)
  7.     {
  8.         if (!self::getConfig()) {
  9.             return;
  10.         }
  11.         $file = self::getStoreConfig('dev/log/exception_file');
  12.         //self::log("\n" . $e->__toString(), Zend_Log::ERR, $file);
  13.         $exceptionDump = "\n\nDETAILED EXCEPTION DUMP\n\n";
  14.         foreach($e->getTrace() as $n=> $t){
  15.             $exceptionDump .= "\n\n------------\n#$n\n" . var_export($t, true) . "\n";
  16.         }
  17.         self::log("\n" . $exceptionDump, Zend_Log::ERR, $file);
  18.     }

More Reading:

 

Leave a Reply