Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '16,': 0.03; 'handler': 0.05; 'one?': 0.05; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Clearing': 0.16; 'wrote:': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'assert': 0.31; 'received:google.com': 0.35; 'subject:?': 0.36; 'pm,': 0.38; 'mar': 0.68; 'otten': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=n9ku77nUHcQhfx7cxx+e/HM0zhN/7mevp453kEbF1zY=; b=iqbbGCh4CXSmu2MVgeszm55nPs9YrOLXdNCirgSrHPcdA/ft610v2obWw4sEUmqbdi HC1nleLiTGgXIXFoHBjzzNszs/3xdpiUw0NsX7Qif2vRcALgsrW2NS44FeSJORv+hkvs w0VatgPgKq5/oyXYXIh+k93+ILcp/V/vzdy0OnqQYZClgXaxvwYycgtdYv51FLA89Kks qgIReDN9eqZp2RcDvoCyIhVA7+i8k8T6t2JIIb6TKi/G3IHTCKWrVrseC2r0OJcLKxXO hgFE3MYK31EtS4se5eonfsj7CDoPBiwJly+j9QPDSKShwggAYQKrjS45p15KlTS5oE57 CTTA== MIME-Version: 1.0 X-Received: by 10.66.146.229 with SMTP id tf5mr19646661pab.50.1394962519329; Sun, 16 Mar 2014 02:35:19 -0700 (PDT) In-Reply-To: References: Date: Sun, 16 Mar 2014 20:35:19 +1100 Subject: Re: Clearing out handlers in logging? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394962522 news.xs4all.nl 2978 [2001:888:2000:d::a6]:44281 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68390 On Sun, Mar 16, 2014 at 8:18 PM, Peter Otten <__peter__@web.de> wrote: > Hm, what do the docs say about this one? > >>>> import logging >>>> logging.basicConfig() >>>> log = logging.getLogger("foo") >>>> for i in range(5): > ... log.addHandler(logging.FileHandler("tmp.log")) > ... >>>> assert len(log.handlers) == 5 >>>> for handler in log.handlers: > ... log.removeHandler(handler) > ... >>>> log.handlers > [, at 0x7f8216f9eb90>] for handler in log.handlers[:]: log.removeHandler(handler) ChrisA