A new way to configure Python logging

Wolodja Wentland wentland at cl.uni-heidelberg.de
Sun Oct 25 08:25:14 EDT 2009


On Sun, Oct 25, 2009 at 10:48 +0000, Vinay Sajip wrote:
> Wolodja Wentland <wentland <at> cl.uni-heidelberg.de> writes:
[ HTMLHandler, multiple configuration files ]

OK! I agree that these parts are hard to standardise and do not really
belong in the *logging* module. 

Maybe a kind soul implements a "configuration" module in the future that
accepts configuration files in a plethora of formats and uses
dictionaries as the lingua franca for final configuration.

> > I will give an example.. The basic problem I have with *all* config file
> > based configuration right now is that I have to *register* every single
> > handler/filter with a logger *within* the configuration or their
> > configuration will be lost.

> You are right, unless handlers (and filters, formatters etc.) are given
> names which can be used to refer to them across multiple configuration calls.
> This is something I am thinking about and will probably update PEP 391
> with my thoughts.

[ usage example ]

> I think your way of working is entirely reasonable, but IMO is not likely to
> be so widespread as to make it worthwile baking into the stdlib. You can
> easily build your own configuration from which you build the dict to pass
> to dictConfig().

Are these two statements not a bit contradictory? If it would be
possible to refer to all major components in logging by *unique* names
would that not mean that the usage example I gave is possible?

I think we managed to single out the sole requirement I would have
towards 'logging' that is missing today.

Id est: The possibility to refer/retrieve/... all major components used
by logging (loggers, handlers, filters, formatters, adaptors) by a
*unique* name. That would enable the developer to deal with them in a
consistent way irregardless of the way they were initially defined
(configuration file, programmatically).

Is this way to deal with logging really that uncommon? I guess I have
to read a lot code to see how other people do it as this would be the
way that feels most natural to me.

BTW, the LoggerAdaptor class looks really useful. I just discovered it
and I have the feeling that I might use it frequently.

> > * Logging Expert
> > * Developer
> > * User

> Those three roles appear reasonable, but I would say that the expert-designed
> blocks would be specialised handlers, filters and formatters. That's not a 
> full-time job, though ;-)

I completely agree. I know that the logging expert and the developer
will most likely be the same person. I just wanted to point out that the
design of the logging system and its components is a different step in
program development than the usage of said system by a developer and
different users.

Thanks again for taking this discussion to the users list. I could have
commented in the -dev thread, but did not. (I ask myself: Why?) I
therefore appreciate it a lot that you try to figure out your users
requirements before implementing them! I just love open source software!

Have a great day and let me know whatever you come up with. 

    Wolodja
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 853 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20091025/22cb0929/attachment-0001.sig>


More information about the Python-list mailing list