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-

-- 
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@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.

Reply via email to