2

After an upgrade from 2.1.9 to 2.2.2, I am getting an error with the use of a Logger class in a custom module. The error is:

PHP Fatal error: Uncaught TypeError: Argument 3 passed to Biztech\Auspost\Model\Carrier\Auspost::__construct() must be an instance of Biztech\Auspost\Logger\Logger, instance of Magento\Framework\Logger\Monolog given, called in /var/www/html/magento-2.2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 111 and defined in /var/www/html/magento-2.2/app/code/Biztech/Auspost/Model/Carrier/Auspost.php:55\nStack trace:\n#0 /var/www/html/magento-2.2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(111): Biztech\Auspost\Model\Carrier\Auspost->__construct(Object(Magento\Framework\App\Config\Interceptor), Object(Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory), Object(Magento\Framework\Logger\Monolog), Object(Magento\Shipping\Model\Rate\ResultFactory), Object(Magento\Quote\Model\Quote\Address\RateResult\MethodFactory), Object(Magento\Framework\App\ObjectManager), Object(Biztech\Auspost\Helper\Data), Object(Magento\Checkout\Model\Cart\Interceptor), Object(Magento\Checkout\Model\Session\I in /var/www/html/magento-2.2/app/code/Biztech/Auspost/Model/Carrier/Auspost.php on line 55

I am definitely passing an instance of Biztech\Auspost\Logger\Logger, so I am not sure why Magento thinks it is an instance of Magento\Framework\Logger\Monolog

The Logger class is defined as:

<?php

namespace Biztech\Auspost\Logger;

class Logger extends \Monolog\Logger {

}

And is called with this constructor:

<?php
namespace Biztech\Auspost\Model\Carrier;

...
use Biztech\Auspost\Logger\Logger;

protected $_logger;

class Auspost extends AbstractCarrier implements CarrierInterface
{

  ...

public function __construct(
    ScopeConfigInterface $scopeConfig,
    ErrorFactory $rateErrorFactory,
    \Biztech\Auspost\Logger\Logger $logger
    ....
{
    $this->_logger = $logger;

I also have a di.xml file as:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <type name="Biztech\Auspost\Logger\Handler">
        <arguments>
            <argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
        </arguments>
    </type>
    <type name="Biztech\Auspost\Logger\Logger">
        <arguments>
            <argument name="name" xsi:type="string">auspost</argument>
            <argument name="handlers"  xsi:type="array">
                <item name="system" xsi:type="object">Biztech\Auspost\Logger\Handler</item>
            </argument>
        </arguments>
    </type>
</config>

closed as off-topic by Manashvi Birla, Jai, Piyush, Dhiren Vasoya, Priyank Jul 31 '18 at 10:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Manashvi Birla, Jai, Piyush, Dhiren Vasoya, Priyank
If this question can be reworded to fit the rules in the help center, please edit the question.

  • can you run php bin/magento setup:upgrade command then check ? – Ansar Husain Jul 31 '18 at 6:57

Browse other questions tagged or ask your own question.