0

I would like to make a global Zend_Log object that I can reach from my Controllers and my Models.

What should I add to my Bootstrap? (My bootstrap extends Zend_Application_Bootstrap)

How then can I reach the logger object from my controller actions and from my model?

tereško
  • 58,060
  • 25
  • 98
  • 150
Peter Smit
  • 27,696
  • 33
  • 111
  • 170

1 Answers1

3

As you do with any other class - assign it to the Zend_Registy. I'd suggest setting like this:

Zend_Registry::set('Zend_Log',$logInstance);

This is a common way, which is used also for translate (set translate instance to 'Zend_Translate' and classes like forms and validators will find it automatically).

You can use Zend_Registry::get('Zend_Log')->log(...) to log anywhere you want. It's not very good from the point of architecture (you should not use normally), but for log - which can appear practically anywhere in the app from view helpers to controllers and models it's a good thing.

Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82