Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68388
| References | <mailman.8159.1394938715.18130.python-list@python.org> <gd.usenet-B1805D.09394016032014@dwarf.main.lan> |
|---|---|
| Date | 2014-03-16 20:02 +1100 |
| Subject | Re: Clearing out handlers in logging? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8163.1394960581.18130.python-list@python.org> (permalink) |
On Sun, Mar 16, 2014 at 7:39 PM, Gunther Dietrich <gd.usenet@spamfence.net> wrote: >>but it feels a little dirty to reach into logging.root.handlers since >>there are other methods for adding/removing handlers. However, as >>best I can tell, to remove a handler, you already need to have it >>saved somewhere. > > What about this: > >>>> for handler in log.handlers: > ... log.removeHandler(handler) > > I think, that's just one of the tasks that removeHandler() was written > for. I'm sure Tim was aware of the removeHandler function. But this is still reaching into log.handlers - although IMO it's safer to reach in and read than to reach in and mutate. So without the implications of Tim's inability to read docs, this is a viable suggestion. I'd prefer this over the original "del log.handlers[:]". ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Clearing out handlers in logging? Tim Chase <python.list@tim.thechases.com> - 2014-03-15 21:58 -0500
Re: Clearing out handlers in logging? Gunther Dietrich <gd.usenet@spamfence.net> - 2014-03-16 09:39 +0100
Re: Clearing out handlers in logging? Chris Angelico <rosuav@gmail.com> - 2014-03-16 20:02 +1100
Re: Clearing out handlers in logging? Peter Otten <__peter__@web.de> - 2014-03-16 10:18 +0100
Re: Clearing out handlers in logging? Chris Angelico <rosuav@gmail.com> - 2014-03-16 20:35 +1100
Re: Clearing out handlers in logging? Tim Chase <python.list@tim.thechases.com> - 2014-03-16 07:57 -0500
Re: Clearing out handlers in logging? Gunther Dietrich <gd.usenet@spamfence.net> - 2014-03-16 19:29 +0100
Re: Clearing out handlers in logging? Tim Chase <python.list@tim.thechases.com> - 2014-03-16 13:50 -0500
csiph-web