Logging in Magento 2

Logging in Magento 2 without and class import or constructor

$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info("DDDDDDD"); //-- this will only log the text
//-- for loggin the array please use this line
$logger->info(print_r($buyRequest, true));

 

 

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.