Siehe auch

User Contributed Notes 2 notes

Honestly, Exception::getTraceAsString() simply sucks, listing only the called method (below, for example, on line 89 function fail2() gets called, but there's no information that you have the originator is fail1()). The fact that, in the example below, the exception gets thrown on line 78, is completely omitted from the trace and only available within the exception. Chained exceptions are not supported as well.

jTraceEx() provides a much better java-like stack trace that includes support for chained exceptions:Exception: Thrown from class C at seabird.test.C.exc(index.php:78) at seabird.test.C.doexc(index.php:70) at seabird.test.fail2(index.php:85) at seabird.test.fail1(index.php:89) at (main)(index.php:93)Caused by: Exception: Thrown from class B at seabird.test.B.exc(index.php:64) at seabird.test.C.exc(index.php:75) ... 4 moreCaused by: Exception: Thrown from class A at seabird.test.A.exc(index.php:46) at seabird.test.B.exc(index.php:61) ... 5 more

this method uses \n for new line (i expected PHP_EOL but well ...).if you want to log the string as one single line use something like:<?php$separator = ', ';$one_line = str_replace("\n", $separator, $e->getTraceAsString());?>