Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'class,': 0.07; 'formatting': 0.07; 'override': 0.07; '__init__': 0.09; 'handlers': 0.09; 'methods,': 0.09; 'received:172.18.0': 0.16; 'specified.': 0.16; 'subject:Logging': 0.16; 'subject:class': 0.16; 'instance': 0.17; 'appropriate': 0.20; 'define': 0.20; 'to:name:python-list@python.org': 0.20; 'object.': 0.22; 'work.': 0.23; 'tried': 0.25; 'thanks!': 0.26; 'logging': 0.27; 'fine': 0.28; 'file': 0.32; 'adjust': 0.33; 'to:addr:python-list': 0.33; 'there': 0.35; 'add': 0.36; 'but': 0.36; "didn't": 0.36; 'does': 0.37; 'object': 0.38; 'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'most': 0.61; 'received:unknown': 0.63; 'within': 0.64; 'few.': 0.93 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=KbdnvV9g8TRf6O+NCh6TOyF5LS0weEPBhaAycnKeCs0= c=1 sm=1 a=CRTDazI5n6YA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=ZdCO1qe3w5B5K02WI80A:9 a=wPNLvfGTeEIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 From: "Joseph L. Casale" To: "python-list@python.org" Subject: Logging within a class Thread-Topic: Logging within a class Thread-Index: AQHOB/XXYuV0u/Qa5Eq9aXDUdXj5Rw== Date: Mon, 11 Feb 2013 01:26:52 +0000 Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.18.0.200] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360546087 news.xs4all.nl 6881 [2001:888:2000:d::a6]:33529 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38629 Within __init__ I setup a log with=A0self.log =3D logging.getLogger('foo') = then add a=0A= console and filehandler which requires the formatting to be specified. Ther= e a few=0A= methods I setup a local log object by calling=A0getChild against the global= log object.=0A= =0A= =0A= This works fine until I need to adjust the=A0formatter for a few. With this= style, I need=0A= to redefine the handlers, so basically=A0setup logging again.=0A= =0A= =0A= I tried to get around this by using=A0basicConfig and simply=A0re-specifyin= g=A0format inside=0A= the few methods, but it didn't work.=0A= =0A= =0A= How does one accomplish this most elegantly so I can define one log instanc= e with=0A= the appropriate general console and file handlers in my class, then simply = override=0A= the formatter for both handlers=A0they use in a couple methods?=0A= =0A= =0A= Thanks!=0A= jlc=