in previous magento version, i used to make a custom logger, using Zend\Log\Logger This was allowing me to create as many logger with custom name as i wanted.

I would like to update this behavior with the most recent logger Psr\Log\LoggerInterface. But turns out, it seems to be only able to define custom filename using xml, which means i can't really have that same flexibility i had with zend; I don't just want my custom logger to have one custom log filename. I want to be able to switch that filename whenever I want, the same way I was doing it with zend $writer = new Stream(BP . '/var/log/'.$this->filename.'.log');

Do you see a way to do this ? Thanks

1 Answer 1


You can use the below code to log the files. I would suggest this type of logs to be used only for temporary purpose.

$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/custom.log');
$logger = new \Zend_Log();
$logger->info('add your log here');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.