Problem with logging module
Diez B. Roggisch
deetsNOSPAM at web.de
Fri Oct 15 11:29:11 EDT 2004
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]:
...
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list