mage log in magento 2 code example
Example 1: mage log magento 2
<?php
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/logfile.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Simple Text Log');
$logger->info('Array Log'.print_r($myArrayVar, true));
?>
Example 2: magento2 zend log
<?php
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/MYLOGFILE.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Your text message');
?>
Example 3: log magento 1
Mage::log('message',null,'logfile.log',true);
Example 4: mage log equivalent magento 2
\Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class)->debug('Your message here');