Magento 2 – Write logs to the custom files

In Magento 2, you can use the following code to write logs to the custom files

$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/templog.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);

$logger->info("Log info: ".  $e->getMessage());

Revisions

No comments yet.

Leave a Reply