Logging in Magento 2.4+

As we all know that after the release of the Magento 2.4.3 version, the Laminas-log module is removed. Thus, the previous method by using the following will not work

quick ways to debug

    $writer = new \Laminas\Log\Writer\Stream(BP . '/var/log/custom.log');
    $logger = new \Laminas\Log\Logger();

So after 2.4.3+

  try {
        $writer = new \Zend_Log_Writer_Stream(BP . '/var/log/custom.log');
    } catch (\Zend_Log_Exception $e) {
        // throw exception
    $logger = new \Zend_Log();
    $logger->info('Debuggging on!');

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Reply

Your email address will not be published. Required fields are marked *