I have a custom module where I'd like to extend the Base Handler

<preference for="Magento\Framework\Logger\Handler\Base" type="Custom\Foo\Handler\DefaultHandler" />

Strangewise this does not work in this specifc case, while other preferences are working fine like

<preference for="Psr\Log\LoggerInterface" type="Custom\BarFoo\Handler\BaseLog" />

Thanks for clarification


  • Any debug information? How do you know that it doesn't work? Dec 16, 2015 at 10:36
  • facing same issue. Have you found any solution? Jul 26, 2018 at 13:30

1 Answer 1


Using this blog post as a walk through on creating a preference:


I walked through the process of creating a preference for the class you are trying to override Magento\Framework\Logger\Handler\Base and it worked like a charm. So there is no structural issue with creating a preference for Base.php.

Given that your other preference is working fine, we can assume that your module is working fine, so the next guess would be that the class you are using isn't correct or there is a typo in there. For my test, I used this:


namespace {vender_namespace}\{module_name}\Model;

use \Magento\Framework\Logger\Handler\Base;

class Log extends Base {


And then created a Demo.php file in the root of my Magento install to test that it is working (per the blog post that I linked to)


require_once 'app/bootstrap.php';

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

$sample = $bootstrap->getObjectManager()->create('Magento\Framework\Logger\Handler\Base');


If the returned value is your class, then you know that the preference is working correctly and there is an issue somewhere else in the code.

  • i have run this script but it's give me error.what is the issue in prefrence? Jul 27, 2018 at 4:56

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.