How do you make MyCompanyMyModuleLogger the default implementation of the LoggerInterface globally?

You are implementing a custom module MyModule, which provides an implementation of PsrLogLoggerInterface called MyCompanyMyModuleLogger.
The LoggerInterface has the default preference declared in app/etc/di.xml.
Keeping upgradability in mind, how do you make MyCompanyMyModuleLogger the default implementation of the LoggerInterface globally?
A. Declare a new preference for the LoggerInterface in app/code/myCompany/MyModule/etc/frontend/di.xml
B. Declare a new preference for the LoggerInterface in MyCompany/MyModule/etc/di.xml
C. Overwrite the existing preference for the LoggerInterface in app/etc/di.xml
D. Declare a new preference for the LoggerInterface in app/code/MyCompany/MyModule/etc/global/di.xml

Download Printable PDF. VALID exam to help you PASS.

9 thoughts on “How do you make MyCompanyMyModuleLogger the default implementation of the LoggerInterface globally?

  1. B is the answer to keep the upgradability, if we are going to edit on the app/etc/di.xml this will make it default to all modules.

    1. Yes you are right from one side. I also thought in the same way. But if you look at the question “how do you make MyCompanyMyModuleLogger the default implementation of the LoggerInterface globally?”, here the main question is about making MyCompanyMyModuleLogger as the default globally. So as per that, C should be the answer. Isn’t it?

      1
      1
      1. The correct answer should be B. Because it will maintain the upgradability and also will be the default logger. If we select C, then practically when magento version will be upgraded, the change will be lost and overriding the core file like this is not good also.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.