Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A replacement for M1's mage::log() for M2
// ------------------------------------------------------------------
// Psr Logging Interface *the right way*
protected $logger;
public function __construct(\Psr\Log\LoggerInterface $logger)
$this->logger = $logger;
// ------------------------------------------------------------------
// direct call to Zend\Log\Writer *the dirty but quick way*
$logfile = BP. '/var/log/my-debug.log';
$writer = new \Zend\Log\Writer\Stream($logfile);
$logger = new \Zend\Log\Logger();
$logger->info(print_r($array, true));
// original code from:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment