Mautic Community Forums

How to log in mautic

Can someone help me with how to log messages in Mautic for debugging a certain issue.
I want something like console.log()
As I am stuck with a problem with mobile notification and there is nothing in logs

Depends on what you want to debug, usually you can inject logger service and use it to log something. If you’re looking to debug at javascript end, I would suggest to go with Debugger in browser console.

mautic/app/config/local.php set debug to “true”

then in ssh run tail -f path/to/your/mautic/var/logs/mautic_prod-2021-01-26.php

Change the date to whatever the date is.

what command to put in code to log it?
error_log() ? this?

$this->factory->getLogger()->log(‘debug’, ‘your message here’);
this worked.
Thanks a lot

how to inject logger service?

not able to log in OneSignalApi.php file. Please help. Urgent.

hello @mayanktiwaridotcom how to inject logger service?

@joeyk can you help me out here?
I am not unable to get mobile notifications working. Any solution would be appreciated

I tried injecting through constructor but getting

mautic.NOTICE: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Mautic\NotificationBundle\Api\OneSignalApi::__construct() must implement interface Psr\Log\LoggerInterface, instance of Joomla\Http\Http given, called in /var/www/html/mautic/var/cache/prod/ContainerAj3mgem/getMautic_Notification_ApiService.php on line 8 (uncaught exception) at /var/www/html/mautic/app/bundles/NotificationBundle/Api/OneSignalApi.php line 32 while running console command `mautic:campaigns:trigger

this error