magento2-custom-logger

Installation
SKILL.md

Magento 2 Custom Logger via di.xml Virtual Types

Give any class its own dedicated log file without creating a real PHP Logger class — everything is wired through XML virtual types.


How it works

Magento's DI container supports virtual types: named aliases for existing classes with different constructor arguments. Two virtual types are needed:

  1. Handler — extends Magento\Framework\Logger\Handler\Base, sets fileName
  2. Logger — extends Magento\Framework\Logger\Monolog, references the handler

etc/di.xml snippet

Installs
6
GitHub Stars
4
First Seen
Mar 16, 2026
magento2-custom-logger — tuanhaviet22/magento-skills