Stucked with python logging module

S

sword

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?
Thanks in advance
 
K

Kushal Kumaran

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top