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


Groups > comp.lang.python > #17146

Re: logging issues

Date 2011-12-13 16:21 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
Subject Re: logging issues
References <4EE77279.10104@gmail.com> <4EE77933.2060705@sequans.com>
Newsgroups comp.lang.python
Message-ID <mailman.3603.1323793282.27778.python-list@python.org> (permalink)

Show all headers | 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