Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17146

Re: logging issues

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'handler': 0.04; 'function,': 0.07; 'etc...': 0.09; 'handler.': 0.09; 'configure': 0.10; 'codebase': 0.16; 'creation.': 0.16; 'logger.': 0.16; 'subject:issues': 0.16; 'subject:logging': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'level,': 0.18; 'modified': 0.18; 'cc:no real name:2**0': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'there.': 0.24; 'raise': 0.28; 'possible?': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'handling': 0.30; 'turned': 0.30; 'really,': 0.30; 'solved': 0.30; 'thanks': 0.31; 'message-id:@gmail.com': 0.33; 'header:User-Agent:1': 0.33; 'handled': 0.34; 'setting': 0.34; 'calling': 0.34; '???': 0.34; 'root': 0.34; 'changing': 0.35; 'modules': 0.35; 'supposed': 0.35; 'except': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'received:10.0.0': 0.38; 'too,': 0.38; 'event': 0.38; 'some': 0.38; 'created': 0.38; 'should': 0.39; 'being': 0.39; 'logs': 0.39; "it's": 0.40; 'one,': 0.40; 'more': 0.61; 'your': 0.61
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=0KQwBsKO3ozOkSwvqwFkWDCLFQdMLlNMdyeX6dCn+58=; b=jK/zjfWs9HTetAYz0D+mnYM7ENaZQIn0QfeEUYqC1S0Vcrqr4FAz8K+03n0/m57umJ gtY8T4g4pE7bYbcOa0JTLprI+GQKmUV+n31IiDO//zDjWD1um26p6coFtyUhEoBgsmb1 Lraf7bekrjU03tVcg7kpRgm+VJmdJpXQ5fCaE=
Date Tue, 13 Dec 2011 16:21:15 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111108 Thunderbird/8.0
MIME-Version 1.0
To Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: logging issues
References <4EE77279.10104@gmail.com> <4EE77933.2060705@sequans.com>
In-Reply-To <4EE77933.2060705@sequans.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3603.1323793282.27778.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323793282 news.xs4all.nl 6958 [2001:888:2000:d::a6]:53762
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17146

Show key headers only | View raw


On 12/13/2011 04:11 PM, Jean-Michel Pichavant wrote:
> Not really, if you use the classic way, your subloggers should be 
> created an never configured. Their default behavior is to raise any 
> log event to its parent. That way, all event logs end up being handled 
> by the root logger.
>

Ok thanks now it's more clear.your codebase which is ???
>
> [snip some working code]
>
> As a general advices
> - try to never configure a child logger, you should only need to 
> create one whithout setting its level nor its handler. A logger is 
> responsible of raising log events, not handling them. The root logger 
> is supposed to handle them.
> - Configure only the root logger and do it in the main function, and 
> only there. Configuring means calling basicConfig, setting the level, 
> adding a handler etc... everything except the creation.
>
> JM

It turned out that I was calling
logger = logging.getLogger()

In other modules too, and then apparently the logging level was
modified automatically to the default one, is that possible?

changing with
logger = logging.getLogger(__name__) everywhere solved my problems..

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: logging issues Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-13 16:21 +0000

csiph-web