1 post tagged

magento2

Log Debug Backtrace in Magento 2

$obj = \Magento\Framework\App\ObjectManager::getInstance();
$fileHandler = $obj->create(\Magento\Framework\Logger\Handler\Base::class, ['fileName' => 'var/log/debug.log']);
$logger = $obj->create(\Monolog\Logger::class, [
                'name' => 'save',
                'handlers' => ['file' => $fileHandler],
                'processors' => ['process_id' => $obj->get(\Monolog\Processor\ProcessIdProcessor::class)]
            ]);
$logger->info(var_export(\Magento\Framework\Debug::backtrace(1, 0, 1), 1));

Result could be found in var/log/debug.log

2018   debug   log   magento2