Skip to content

Magento 2 – Get stacktrace

I try to figure out the exact stack trace after I click on a link for example the link which prints the order PDF in the customer area.

I tried it by adding the following code after $response = $application->launch();:

// vendor/magento/framework/App/Bootstrap.php

    ...
    $response = $application->launch();

    $writer = new ZendLogWriterStream(BP . '/var/log/zend_debug.log');
    $logger = new ZendLogLogger();
    $logger->addWriter($writer);
    
    // Stacktrace:
    
        $debugBackTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        foreach ($debugBackTrace as $item) {
            $logger->info(@$item['class'] . @$item['type'] . @$item['function']);
        } 
    ...

But it just logs “MagentoFrameworkAppBootstrap->run“.