On 1/5/2023 4:28 PM, Weatherby,Gerard wrote:
logging.basicConfig()
logging.info(“Nice to know”)
logging.debug(“Details for when things are funky”)
logging.warn(“Trouble is brewing”)
Not quite -
>>> import logging
>>> logging.basicConfig()
>>> logging.info("Nice to know")
>>> logging.debug("Details for when things are funky")
>>> logging.warn("Trouble is brewing")
<stdin>:1: DeprecationWarning: The 'warn' function is deprecated, use
'warning' instead
WARNING:root:Trouble is brewing
Only warning level messages are displayed, unless you do some
configuration, as mentioned in the logging Howto page:
"The default level is WARNING, which means that only events of this
level and above will be tracked, unless the logging package is
configured to do otherwise."
So following the Howto:
>>> logging.basicConfig(level=logging.DEBUG)
>>> logging.info('So should this')
INFO:root:So should this
: Finally!
Not quite straightforward, though it is in the Howto. Now about those
handlers ...
From: Python-list <python-list-bounces+gweatherby=uchc....@python.org> on behalf of
Grant Edwards <grant.b.edwa...@gmail.com>
Date: Thursday, January 5, 2023 at 3:31 PM
To: python-list@python.org <python-list@python.org>
Subject: Re: What should go to stdout/stderr and why Python logging write
everything to stderr?
*** Attention: This is an external email. Use caution responding, opening
attachments or clicking on links. ***
On 2023-01-05, Thomas Passin <li...@tompassin.net> wrote:
The logging system is so configurable that...
I find it almost impossible to use unless I copy a working example I
find somewhere. ;)
I'm not at all surprised that the OP didn't understand how it
works. I've been writing Python programs for over 20 years, and it's
beyond me.
--
Grant
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l6vSXQFKppEuLS0R5gYeLYaiHyVFfs2Rapqm1oPGEtvnZ5ivQyApZcnJyNTnnH9zEVY80ajNb-HfYkNwgw8fMtsnlSOT$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l6vSXQFKppEuLS0R5gYeLYaiHyVFfs2Rapqm1oPGEtvnZ5ivQyApZcnJyNTnnH9zEVY80ajNb-HfYkNwgw8fMtsnlSOT$>
--
https://mail.python.org/mailman/listinfo/python-list