In order to create a logging event that logs specific data to a seperate file, simply create a sfFileLogger instance and connect it to your application’s event dispatcher.
In apps/frontend/config/frontendConfiguration.class.php
class frontendConfiguration extends sfApplicationConfiguration { public function configure() { $mylogger = new sfFileLogger(new sfEventDispatcher, array( ’file‘ => $this->getRootDir().‘/log/mylog.log‘ )); $this->dispatcher->connect(‘mylog.log‘, array($mylogger, ‘listenToLogEvent‘)); } }
Now, you can log into that file by notifying the event from anywhere in your application :
$dispatcher = sfContext::getInstance()->getEventDispatcher(); $dispatcher->notify(new sfEvent($this, ‘mylog.log‘, array(‘hello‘)));
One Reply
[...] scales and arpeggios Symfony development blog About « Logging in Symfony 1.1 Creating a custom logging event [...]