php - Correct way to log from Entities and Repositories in Symfony2 -
what way log messages or errors entity or repository class in symfony2 architecture? in symfony1 use singleton kill puppies doing logger anywhere:
sfcontext::getinstance()->getlogger()
symfony2's container model stricter, great, how should 1 go logging non-container-aware classes? repos, guess can define them (all) services, dependency on logger, , go there. when have instance of entity class?
historically i'd want put log message inside class methods, now? should pass logger (as parameter) every class method wants write log message? seems bit of overkill perhaps it's best practice?
or looking @ wrong , entities or repos shouldn't writing log messages passing them controller handle?
you should avoid putting business logic (even logging) inside entity model.
as repositories, way described right one.
Comments
Post a Comment