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

10 views

Recent Posts

See All

Follow Me

  • LinkedIn
  • Twitter
  • Facebook
  • YouTube
  • Instagram

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