Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35724

Re: Confused about logger config from within Python (3)

From Peter Otten <__peter__@web.de>
Subject Re: Confused about logger config from within Python (3)
Date 2012-12-29 01:56 +0100
Organization None
References <a51d0c8a-adc9-4d8e-b3cc-affd7c6aad95@googlegroups.com> <3149c22d-ae6d-43b4-8f88-3cc5fa91094c@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1413.1356742618.29569.python-list@python.org> (permalink)

Show all headers | View raw


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> ;)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Confused about logger config from within Python (3) andrew cooke <andrew@acooke.org> - 2012-12-28 11:57 -0800
  Re: Confused about logger config from within Python (3) andrew cooke <andrew@acooke.org> - 2012-12-28 16:41 -0800
    Re: Confused about logger config from within Python (3) Peter Otten <__peter__@web.de> - 2012-12-29 01:56 +0100
      Re: Confused about logger config from within Python (3) andrew cooke <andrew@acooke.org> - 2012-12-28 18:29 -0800
        Re: Confused about logger config from within Python (3) Dave Angel <d@davea.name> - 2012-12-28 22:02 -0500
      Re: Confused about logger config from within Python (3) andrew cooke <andrew@acooke.org> - 2012-12-28 18:29 -0800
    Re: Confused about logger config from within Python (3) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-29 05:05 +0000
      Re: Confused about logger config from within Python (3) Roy Smith <roy@panix.com> - 2012-12-29 08:48 -0500
        Re: Confused about logger config from within Python (3) Terry Reedy <tjreedy@udel.edu> - 2012-12-29 19:18 -0500
          Re: Confused about logger config from within Python (3) Roy Smith <roy@panix.com> - 2012-12-29 20:08 -0500
  Re: Confused about logger config from within Python (3) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-29 04:31 +0000

csiph-web