Magento – How to print or debug array or object in Magento 2

debuglogmagento2

I am working on Magento 2.

if ($this->getRequest()->isAjax()) {
    $layout =  $this->_layout;
}

How can I print or debug value of $layout in above code ??

Best Answer

On top of what Ashar Riaz said, you can also use the debug method from \Psr\Log\LoggerInterface :

$this->_logger->debug(var_export($layout, true));

IIRC, the values will be logged under var/log/debug.log

Related Topic