top of page

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 ) );
}

Recent Posts

See All

Comments


Follow Me

  • LinkedIn
  • Twitter
  • Facebook
  • YouTube
  • Instagram

©2021 by Bilal Usean. Proudly created with Wix.com

bottom of page