Hi Peter,
You can initialise the Zend_Log instance from a method on the bootstrap called
_initLog(), and return it from that method (essential). Then all you need to do
from any action to get the object is
$this->getInvokeArg('bootstrap')->getResource('Log'). If you need it in a
Model, it depends how the Model works, where it is instantiated, etc. But
generally you want to inject the Log into the Model through its constructor or
a setter (assuming it's the same object you need!).
You can set up multiple logs in a similar way used specifically named bootstrap
methods, or a single bootstrap method that creates an array or object
collection of needed logs. If you dig around the Incubator there's a class
called Zend_Cache_Manager where I lazy load caches using "configuration
templates". You can do something similar with Logs (it's a really simple class)
to configure them up front, but only instantiate Log objects when they are
really needed (lazy loading).
Paddy
Pádraic Brady
http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative
________________________________
From: Peter Smit <[email protected]>
To: [email protected]
Sent: Sun, October 11, 2009 8:53:05 AM
Subject: [fw-general] How to make a global Zend_Log with
Zend_Application_Bootstrap
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?Regards,
Peter Smit