Last active
May 4, 2022 15:25
-
-
Save DominicWatts/6a49be6a99752e8b09cf1c56862b295c to your computer and use it in GitHub Desktop.
Magento 2 Write to Custom Log Files
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
// quick log | |
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log'); | |
$logger = new \Zend\Log\Logger(); | |
$logger->addWriter($writer); | |
$logger->info('Your text message'); | |
// 2.4.3 + syntax | |
$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/test.log'); | |
$logger = new \Zend_Log(); | |
$logger->addWriter($writer); | |
$logger->info('Your text message'); | |
$logger->info(print_r($yourArray, true)); | |
\Magento\Framework\App\ObjectManager::getInstance() | |
->get(\Psr\Log\LoggerInterface::class)->debug('message'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment