Logging module, a few questions

Vinay Sajip vinay_sajip at yahoo.co.uk
Thu Jun 3 16:18:53 CEST 2004


Irmen de Jong <irmen at -nospam-remove-this-xs4all.nl> wrote in message news:<40a134f7$0$64453$e4fe514c at news.xs4all.nl>...
> > I'm using a configuration file to set up the logging.
> > 
> > Which brings me to another thing.
> > In java's log4j, it's easy to "silence" or "enable" specific
> > parts of a logging hierarchy, by doing:
> > 
> > log4j.category.nl.company = DEBUG
> > log4j.category.nl.company.lib = WARN
> > log4j.category.org.apache = WARN
> > 
> > and so on.
> > 
> > I see no easy way of doing the same for Python's logging module;
> > it seems that I have to create a handler for each of the different
> > parts of the hierarchy of which I want to set the loglevel.
> > Am I missing something?
> 

Since you are using a configuration file, you can set up config
entries for each logger for which you want to configure a level. For
example:

[loggers]
keys=root,log02,log03,log04

[logger_log02]
level=DEBUG
propagate=1
qualname=nl.company

[logger_log03]
level=WARN
propagate=1
qualname=nl.company.lib

[logger_log04]
level=WARN
propagate=1
qualname=org.apache

Regards,


Vinay Sajip



More information about the Python-list mailing list