Magento 2 print log -How to print log in Magento 2

Magento 2 print log -How to print log in Magento 2

In this post we will show you Magento 2 print log, hear for Magento 2 print log we will give you demo and example for implement.

Write the Below code for print the exception in a custom log file in Magento 2.

code for Magento2 print log

	
$writerData = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$loggerData = new \Zend\Log\Logger();
$loggerData->addWriter($writerData);
$loggerData->info($exception);

Where $exception is the exception object.

Hope this code and post will helped you for implement Magento2 print log. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org