What should go to stdout/stderr and why Python logging write everything to stderr?

Barry Scott barry at barrys-emacs.org
Wed Jan 4 12:49:57 EST 2023


On 03/01/2023 21:24, c.buhtz at posteo.jp wrote:
> Am 03.01.2023 17:51 schrieb ram at zedat.fu-berlin.de:
>> logging.getLogger().addHandler( logging.StreamHandler( sys.stdout ))
>
> But I don't want to make all log levels go to stdout. Just DEBUG and 
> INFO. But this would be a workaround.
>
> The main question here is why does Python deciecded to make all logs 
> go to stderr?
> Maybe I totally misunderstood the intention of logging.info()?! Isn't 
> this the "usual applicaton output"?
>
> If not, what messages should go into logging.info()? Can you name me 
> some examples?

It is up to you, the designer of an application, to decide how it works.
You will take into account conventions that your users will expect you 
to follow.

If the logging module helps you then use it, but you are not forced by 
logging to
design your app is a particular way. The default behavior of the logging 
module is
a generally useful default, but its only a default. You are free to 
setup logging to
meet your needs.

Barry




More information about the Python-list mailing list