1

Magento 2 old versions like magento 2.4.0 are accepted like taht

I found a solution to fixed custom log t Magento 2.4.3+++++:

$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/mycustom.log');
$logger = new \Zend_Log();
$logger->addWriter($writer);
$logger->info("Its working successfully...");

I hove it will help for you!

  • 1
    It's best to actually ask the question & provide an answer afterwards. Then accept that answer. This helps readers find questions that are similar nature & will help people answering questions to not unnecessarily spend time reading your question just to realize that it is already answered. – augsteyer Dec 15 '22 at 18:55

2 Answers2

1

This will work with magento 2.4.5

$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/custom.log');
$logger = new \Zend_Log();
$logger->addWriter($writer);
$logger->info('test');
Rajeev Singh
  • 143
  • 10
0

in root project. in composer.json file

verify this: "require": { "zendframework/zend-log": "^2.13" }

if not write this: composer require laminas/laminas-log

https://docs.laminas.dev/laminas-log/installation/

  • logging in Magento has its own approach that should be followed (and with 2.4.5 monolog is being used); Zend_Log_Writer_Stream should not be called directly. – FlorinelChis Jul 22 '23 at 18:16
  • logging in Magento has its own approach that should be followed (and with 2.4.5 monolog is being used); Zend_Log_Writer_Stream should not be called directly. – – FlorinelChis Jul 22 '23 at 18:16