Created
April 2, 2020 13:26
-
-
Save atishgoswami/d4566015231e74f0b3a14fb5b75d107a to your computer and use it in GitHub Desktop.
Quick Logging with Magento2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// FYI : This is just to implement quick logging | |
// for debugging purposes on local not fix | |
// for production level application logging | |
❌ // Don't Use Zend Logger | |
$logger = new \Zend\Log\Logger(); | |
$logger->addWriter(new \Zend\Log\Writer\Stream(BP . '/var/log/test.log')); | |
$logger->info('Your text message'); | |
✔️ // Use Monolog | |
$log = new \Monolog\Logger('custom', [new \Monolog\Handler\StreamHandler(BP.'/var/log/test.log')]); | |
$log->info('Your Logging Message', ['context' => ['email' => 'john@example.com']]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment