Confused about logger config from within Python (3)
Peter Otten
__peter__ at web.de
Fri Dec 28 19:56:46 EST 2012
andrew cooke wrote:
> similarly, if i run the following, i see only "done":
>
> from logging import DEBUG, root, getLogger
>
> if __name__ == '__main__':
> root.setLevel(DEBUG)
> getLogger(__name__).debug("hello world")
> print('done')
You need a handler. The easiest way to get one is logging.basicConfig().
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> logging.getLogger().debug("goodbye, cruel world")
DEBUG:root:goodbye, cruel world
Other revolutionary ideas: read the docs
<http://docs.python.org/dev/howto/logging.html#logging-basic-tutorial> ;)
More information about the Python-list
mailing list