Your software
My Mautic version is: 3.3.3
My PHP version is: 7.3.27-9+ubuntu18.04.1+deb.sury.org+1
My Database type and version is: MySQLServer 5.7.33-google-log
Your problem
My problem is: Error on printing logs with:
$this->factory->getLogger()->log('error', 'TEST: ' . $campaignCategory->getId() . ', CampaignName: ' . $campaignName );
On mautic 2 was logging fine, and after the upgrade made upgrade of the external plugin (that works on mautic 3.3.3), but can’t use getLogger() anymore.
These errors are showing in the log:
mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: “Call to a member function getLogger() on null” at /var/www/html/mauticqa2/plugins/MauticTekeverBundle/EventListener/TekeverCampaignSubscriber.php line 117 {“exception”:"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to a member function getLogger() on null at /var/www/html/mauticqa2/plugins/MauticTekeverBundle/EventListener/TekeverCampaignSubscriber.php:117)
[stacktrace]
#0 /var/www/html/mauticqa2/vendor/symfony/event-dispatcher/EventDispatcher.php(214): MauticPlugin\MauticTekeverBundle\EventListener\TekeverCampaignSubscriber->onCampaignPostSave(Object(Mautic\CampaignBundle\Event\CampaignEvent), ‘mautic.campaign…’, Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher))
#1 /var/www/html/mauticqa2/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, ‘mautic.campaign…’, Object(Mautic\CampaignBundle\Event\CampaignEvent))
#2 /var/www/html/mauticqa2/app/bundles/CampaignBundle/Model/CampaignModel.php(218): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(‘mautic.campaign…’, Object(Mautic\CampaignBundle\Event\CampaignEvent))
#3 /var/www/html/mauticqa2/app/bundles/CoreBundle/Model/FormModel.php(112): Mautic\CampaignBundle\Model\CampaignModel->dispatchEvent(‘post_save’, Object(Mautic\CampaignBundle\Entity\Campaign), true, Object(Mautic\CampaignBundle\Event\CampaignEvent))
#4 /var/www/html/mauticqa2/app/bundles/CoreBundle/Controller/AbstractStandardFormController.php(425): Mautic\CoreBundle\Model\FormModel->saveEntity(Object(Mautic\CampaignBundle\Entity\Campaign), true)
#5 /var/www/html/mauticqa2/app/bundles/CampaignBundle/Controller/CampaignController.php(161): Mautic\CoreBundle\Controller\AbstractStandardFormController->editStandard(‘mautic_b67c71d8…’, ‘’)
#6 /var/www/html/mauticqa2/app/bundles/CoreBundle/Controller/CommonController.php(456): Mautic\CampaignBundle\Controller\CampaignController->editAction(‘mautic_b67c71d8…’, ‘’)
#7 /var/www/html/mauticqa2/vendor/symfony/http-kernel/HttpKernel.php(151): Mautic\CoreBundle\Controller\CommonController->executeAction(‘edit’, ‘mautic_b67c71d8…’, 0, ‘’)
#8 /var/www/html/mauticqa2/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#9 /var/www/html/mauticqa2/vendor/symfony/http-kernel/Kernel.php(200): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /var/www/html/mauticqa2/app/AppKernel.php(104): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /var/www/html/mauticqa2/app/middlewares/CORSMiddleware.php(91): AppKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /var/www/html/mauticqa2/app/middlewares/CatchExceptionMiddleware.php(43): Mautic\Middleware\CORSMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /var/www/html/mauticqa2/app/middlewares/VersionCheckMiddleware.php(67): Mautic\Middleware\CatchExceptionMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/mauticqa2/app/middlewares/TrustMiddleware.php(51): Mautic\Middleware\VersionCheckMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/mauticqa2/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Mautic\Middleware\TrustMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/mauticqa2/vendor/stack/run/src/Stack/run.php(13): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
un(Object(Stack\StackedHttpKernel))p(24): Stack\
Steps I have tried to fix the problem:
I tried to log with other solutions, but has other errors:
$logger = $this->get(‘monolog.logger.mautic’);
$logger->log(‘error’, 'ERROR tekever: ');
what are the steps to print a simple log in the mautic log file, in mautic v3?