Closed hngl closed 6 years ago
After some more testing, I can make the following distinction.
Errors logged via a call to Monolog, are logged once.
$psrLogger->error('Testing Rollbar', ['someVar' => 'someValue']);
Uncaught Exceptions
are logged twice.
throw new TestingRollbarException('Is this thing on?');
The problem is caused by having the bundle register listeners for the kernel.exception
event, in addition to Symfony listeners, which log to Monolog.
Symfony standard registers the Symfony\Component\HttpKernel\EventListener\ExceptionListener::logKernelException()
listener. This listener sends the exception to the default logger . That is usually Monolog.
Output of bin/console debug:event-dispatcher kernel.exception
:
"kernel.exception" event
------------------------
------- ------------------------------------------------------------------------------------ ----------
Order Callable Priority
------- ------------------------------------------------------------------------------------ ----------
#1 App\Api\EventSubscriber\ApiExceptionSubscriber::handleApiException() 2049
#2 App\EventSubscriber\AccountExceptionSubscriber::handleUnknownAccountException() 3
#3 App\EventSubscriber\AccountExceptionSubscriber::handleExpiredAccountException() 2
#4 Rollbar\Symfony\RollbarBundle\EventListener\ErrorListener::onKernelException() 0
#5 Symfony\Component\HttpKernel\EventListener\ExceptionListener::logKernelException() 0
#6 Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onException() 0
#7 Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelException() -64
#8 Rollbar\Symfony\RollbarBundle\EventListener\ExceptionListener::onKernelException() -100
#9 Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException() -128
------- ------------------------------------------------------------------------------------ ----------
That is how when using this SDK, uncaught exceptions show up twice in Rollbar.
@ArturMoczulski Could you please remove the listeners?
@hngl thank you for PR. I merged it in. phpunit
exiting with a non-zero status will be resolved as a separate issue since I identified the problem happening in the master
branch as well.
When using a basic Symfony 4 setup with the setup of the bundle as described in the Rollbar Symfony docs, one Exception thrown becomes 2 lines in the occurrences table.
Setup
config/bundles.php
config/packages/prod/rollbar.yaml
config/packages/monolog.yaml
config/packages/prod/monolog.yaml