I have average experience with python, btw i just installed eclipse and pydev on top of it. And strangely the behavior of logging module looks weird.
import datetime
import logging
print datetime.date.today()
print logging
logging.info("test")
print logging.info("test2")
--------
OUTPUT::
--------
2012-10-25
<module 'logging' from '/usr/lib/python2.7/logging/__init__.pyc'>
None
Any clue why logging.info din't work ?
btw not sure if this is related, but just after pydev installation import logging itself wasn't working. Then i checked python interpreter setting and logging module wasn't there in forced builtins list (Windows->preference->Pydev->Interpreter(python)->Forced Builtins). So i added that manually to make import logging work. Thanks in advance for any pointers.
您可以在第一个日志记录语句之前使用setLevel
更改默认级别。
logging.getLogger().setLevel(logging.DEBUG)
Try this if want to write into stdout:
import sys
import logging
logger = logging.getLogger()
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.info('teste')
Output:
teste
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.