Stucked with python logging module

Kushal Kumaran kushal.kumaran+python at gmail.com
Wed Nov 16 00:13:10 EST 2011


On Wed, Nov 16, 2011 at 8:58 AM, sword <john.37 at gmail.com> wrote:
> I just scaned through the beginer's guide of logging module, but I
> can't get anything from console. The demo just like this:
>
> import logging
> logging.debug("This is a demo")
>
> Maybe I should do sth to put the log to stdout in basicConfig first?

Actually, the problem is not of the output location, but of the
logging level.  In the default configuration, logs at DEBUG level are
suppressed.  logging.basicConfig will be a simple way to change this.
Are you following the logging documentation at
http://docs.python.org/py3k/howto/logging.html#logging-basic-tutorial?
 This page is part of the documentation of the logging module, and is
suitable for first-time logging module users.

In your case, you can do this:

import logging
logging.basicConfig(level=logging.DEBUG)
logging.debug("This is a demo")

-- 
regards,
kushal



More information about the Python-list mailing list