0

How I can create my own custom logger in magento2 ?

In Magento 1, We simply write own custom log with the following code:

Mage::log("Log Message", null, "log_file.log"); 
Deepak MageDivine
  • 507
  • 1
  • 5
  • 23
  • $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/mylog.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info("Your comment ".$variables); – Manish May 07 '16 at 11:05
  • I think the right duplicate question/answer is here: https://magento.stackexchange.com/questions/75935/how-to-create-custom-log-file-in-magento-2/75954#75954 – Siarhey Uchukhlebau Jun 30 '17 at 08:14

1 Answers1

0

For logging OR creating log file, you should use class "Magento\Framework\Logger\Monolog".

For more see here : http://inchoo.net/magento-2/magento-2-logging/

Anil Suthar
  • 4,731
  • 1
  • 14
  • 22