Hello So instead of $logger->info() I should write something like this?
$this->getEventDispatcher()->notify(new sfEvent($this, 'blah.log', array('loglevel'=>'info', 'msg'=>'hello world')); Well, that would not exactly be more elegant than: $logger = BlahLogger::getInstance()->info("hello world"); bye, -christian- On Thu, 25 Feb 2010 10:21:00 -0800 (PST) Richtermeister <nex...@gmail.com> wrote: > Hey Chris, > > you don't need to interact with this logger directly. It just sits > there and listens for your custom logging events. > The dispatcher is what you need to worry about, since that's used to > dispatch the events in the first place. You'll find that the > dispatcher is more available throughout the application than the > logger is, so stick with events to trigger logging. > > Daniel > > > On Feb 25, 9:21 am, Christian Hammers <c...@lathspell.de> wrote: > > Hello > > > > But how do I get an instance of this class? > > > > Or maybe we have a misunderstanding: I do not want > > $this->getLogger()->info() > > to log into the default logfile as well as into my custom logfile. I want > > separate logfile just for special notes which should also not appear in > > the regular log files. > > > > bye, > > > > -christian- > > > > On Wed, 24 Feb 2010 09:25:45 -0800 (PST) > > > > Richtermeister <nex...@gmail.com> wrote: > > > Hey Christian, > > > > > it's simpler than that. > > > Look in your factories.yml at the bottom where the loggers are being > > > set up. > > > The main logger is an aggregate logger, and you can add your logger to > > > this like so: > > > > > (under loggers) > > > my_logger: > > > class: BlahLogger > > > param: > > > level: whateverlevel > > > file: path_to_file > > > > > That starts this logger automatically, and since it only listens to > > > your specialized events, it shouldn't get into the way.. > > > > > Daniel > > > > > On Feb 24, 4:59 am, Christian Hammers <c...@lathspell.de> wrote: > > > > Hello > > > > > > Thanks for this hint! > > > > > > I could not figure out how to use the factory.yml without interfering > > > > with the standard logger as you apparently can't create arbitrary > > > > objects with it. > > > > > > But after adding the following function: > > > > class BlahLogger { > > > > public static function getInstance() { > > > > return new NcLogger( > > > > sfContext::getInstance()->getEventDispatcher(), > > > > array('level'=>'debug', 'file'=> > > > > sfConfig::get('sf_log_dir').'/nc.log')); > > > > } > > > > ... your initialize() ... > > > > } > > > > > > I can now use it like this: > > > > $logger = BlahLogger::getInstance(); > > > > $logger->info("hello world"); > > > > > > bye, > > > > > > -christian- > > > > > > On Tue, 23 Feb 2010 21:22:00 -0800 (PST) > > > > > > Richtermeister <nex...@gmail.com> wrote: > > > > > Hey Christian, > > > > > > > yeah, I've had some trouble with that as well, but I think I found a > > > > > good solution. > > > > > First, I continue to use the regular event system to send log events, > > > > > but I send events of type "blah.log" instead of "application.log". > > > > > Now, to catch those you have to implement a custom logger like so: > > > > > > > class BlahLogger extends sfFileLogger > > > > > { > > > > > public function initialize(sfEventDispatcher $dispatcher, $options = > > > > > array()) > > > > > { > > > > > parent::initialize($dispatcher, $options); > > > > > $dispatcher -> disconnect('application.log', array($this, > > > > > 'listenToLogEvent')); > > > > > $dispatcher -> connect('blah.log', array($this, > > > > > 'listenToLogEvent')); > > > > > } > > > > > } > > > > > > > You can then instantiate this logger anywhere (either by adding it to > > > > > your factories.yml file, or instantiating it directly.) > > > > > > > Hope this helps. > > > > > > > Daniel > > > > > > > On Feb 23, 9:14 am, Christian Hammers <c...@lathspell.de> wrote: > > > > > > Hello > > > > > > > > Is it possible to define a custom sfFileLogger() in factories.yml > > > > > > that works > > > > > > completely independend from the standard frontend.log? It should be > > > > > > accessed > > > > > > like e.g. sfContext::getLogger("myAppLog")->info("remember that"); > > > > > > Just that getLogger() does not take an argument and I'm probably > > > > > > trying it > > > > > > the completely wrong way again :) > > > > > > > > bye, > > > > > > > > -christian- > -- 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