Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question