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

11 views0 comments

Recent Posts

See All

How to generate bearer token - Magento 2 REST API

We can generate the admin bearer token using the below command. Please run the below command in the terminal to generate a token. curl -XPOST -H 'Content-Type: application/json' http://www.domain.com/

Follow Me

  • LinkedIn
  • Twitter
  • Facebook
  • YouTube
  • Instagram

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