On Wed, Dec 12, 2012 at 10:02 AM, Björn Rylander <[email protected]> wrote:
> I have an application where I want to do extensive logging to a database.
> I've found two methods, using the EventManager to attach events to specific
> class methods or registering a factory with the ServiceLocator and extract
> the log in the controllers and pass it to affected classes.
>
> Which method is the preferred ZF2-style? Is it one of the above or perhaps
> some other method altogether? Are there any good examples available?

I tend to think of logging as both an orthogonal concern and a
cross-cutting concern. In other words, it typically isn't a primary
function/responsibility of a given class, and simultaneously is
something that cuts across many different classes.

As such, I tend to log by using the event system; anywhere I might
want to log, I'll trigger an event; this also allows me to tie into
those events and do other things if desired (e.g., sending
notification emails, caching, etc.)



--
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to