Using sfContext has its problems, as you have seen. It couples your models and where you can create your own context in your own tasks, that doesn't solve the problem with standard tasks.
How about using the event dispatcher? In your model: class Something { protected $dispatcher; public function __construct(sfDispatcher $dispatcher = null) { if ($dispatcher) { $this->dispatcher = $dispatcher; } else { $this->dispatcher = ProjectConfiguration::getActive()- >getEventDispatcher(); } } public function log($message, $priority = sfLogger::ERR) { $this->dispatcher->notify(new sfEvent($this, 'application.log', array('message' => $message, 'priority' => $priority))); } } You'll need to set the logger for the prod environment to sfAggregateLogger instead of sfNoLogger and set your level, etc. Hope this helps. On Feb 17, 4:09 am, davidsonrob <rob.davidso...@gmail.com> wrote: > Hi, > > As the complexity of my models has grown I have felt the need to log > errors in the model to help me thoubleshoot > > The way I have been doing it is something like > > sfContext::getInstance()->getLogger()>err('{artistImage} > getImageThumbPath unexpected thumbnailType input param'); > > Which all works fine, it gives me a nice little error in my > debugtoolbar. > > However when I use the CLI for tasks such as > php symfony doctrine:build --all > > rebuilding models etc I get an sfContext error. > > ... So what would be the corrrect way for me to log errors in my model? -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en