How to write custom logs in Magento 2

We can use the below functions to anywhere like Models, Helper, Controller..etc and call wherever you need to print logs.

public function culog($msg) {
$writer = new \Zend\Log\Writer\Stream ( BP . '/var/log/pdp.log' );
$logger = new \Zend\Log\Logger ();
$logger->addWriter ( $writer );
$logger->info ( print_r ( $msg, true ) );


About Bilal

I'm a software programmer, I handle Magento2 modifications at any level.

View all posts by Bilal →

Leave a Reply

Your email address will not be published. Required fields are marked *