Problem with logging module

Steve Erickson steve_erickson at hotmail.com
Wed Oct 20 15:50:43 CEST 2004


"Diez B. Roggisch" <deetsNOSPAM at web.de> wrote in message news:<ckoqcc$gp0$03$1 at news.t-online.com>...
> Steve Erickson wrote:
> 
> > Thanks a bunch for your patience and explanations.  It would be nice
> > if there was a method of checking the logger or handler for an
> > instance of it:
> > 
> > logger = logging.getLogger(name)
> > if not logger.handler(dir + '/' + name + '.log'):
> >     logger.propagate = False
> >     handler = logging.FileHandler(dir + '/' + name + '.log')
> >     logger.addHandler(handler)
> 
> There is the (unfortunately undocumented) property "handlers" on a Logger
> insnstance that you can use:
> 
> if not fname in [h.stream.name for h in logger.handlers]:
>     ...

Excellent!!  Thanks.



More information about the Python-list mailing list