B
B
BonBon Slick2018-07-12 21:20:01
PHP
BonBon Slick, 2018-07-12 21:20:01

Best option for logging Exception?

1 - Trait
2 - Command https://symfony.com/doc/current/components/messeng...
3 - Event https://symfony.com/doc/current/components/event_d...
Perhaps there are some other options , this is a kind of logging module. Since events with the Domain Model are ES and logging is automatic there, unlike Exception, which can get out anywhere and anytime.
It is necessary to log the exceptions to different files by priority.
Example:
infoException - simple exception, sometimes it crashes.
criticalException - critical exception, you need to urgently check what's wrong, naturally the files are different as well as additional info.
It may be necessary to make additional injections and perform some additional actions depending on the level of the action.
To the primer in case of a critical exception, send an email, sms, etc., that is, there are already service injections and additional actions. Unlike infoException, which is simply written to a file.
Also, not only logging of actions, perhaps some actions important for the application that are not related to the Domain Model. The rest, as for me, is already more than ES, Domain Model, and there I have my own implementation with prooph components.
P.S. I personally tend to dispatch the event.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitriy, 2018-07-12
@BonBonSlick

firstly, if you write a functional that will be used in other code, you should not think for him which exception at which logging level to use, and this is exactly how you do criticalException and infoException , maybe infoException will be critical for it.
I would start with the service layer and basic CRUD actions like OrderNotFound,OrderNotCreate,OrderNotDelete etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question