Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?
vinay_sajip at yahoo.co.uk
Sat Sep 3 00:59:31 CEST 2011
On Aug 30, 9:53 am, Michel Albert <exh... at gmail.com> wrote:
> Unfortunately this setup makes `logging.basicConfig` pretty useless.
> However, I believe that this is something that more people could
> benefit from. I also believe, that it just "makes sense" to send
> warnings (and above) to `stderr`, the rest to `stdout`.
> So I was thinking: "Why does `logging.basicConfig` not behave that
Because what seems entirely natural and obvious to you might not seem
so for someone else. The API in the stdlib tries to provide baseline
functionality which others can build on. For example, if you always
have a particular pattern which you use, you can always write a
utility function to set things up exactly how you like, and others who
want to set things up differently (for whatever reason) can do the
same thing, without having to come into conflict (if that's not too
strong a word) with views different from their own.
> Naturally, I was thinking of writing a patch against the python
> codebase and submit it as a suggestion. But before doing so, I would
> like to hear your thoughts on this. Does it make sense to you too or
> am I on the wrong track? Are there any downsides I am missing?
Python 2.x is closed to feature changes, and Python 2.7 and Python 3.2
already support flexible configuration using dictConfig() - see
Also, Python 3.3 will support passing a list of handlers to
which will allow you to do what you want quite easily.
More information about the Python-list