logging issues

Andrea Crotti andrea.crotti.0 at gmail.com
Tue Dec 13 11:21:15 EST 2011


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..



More information about the Python-list mailing list