Skip to content

Instantly share code, notes, and snippets.

@atishgoswami
Created April 2, 2020 13:26
Show Gist options
  • Save atishgoswami/d4566015231e74f0b3a14fb5b75d107a to your computer and use it in GitHub Desktop.
Save atishgoswami/d4566015231e74f0b3a14fb5b75d107a to your computer and use it in GitHub Desktop.
Quick Logging with Magento2
<?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