Python 如何在Gevent中使用日志记录?
我的代码如下:Python 如何在Gevent中使用日志记录?,python,gevent,Python,Gevent,我的代码如下: log = logging.getLogger(__file__) def func(): print "1" log.debug("Printed") g = gevent.spawn(func) g.join() 但是当我运行它时,我的日志不会显示在shell中。有什么想法吗?是否有更好的方法在基于gevent的协同程序中进行日志记录?它与gevent无关。您应该配置,例如 谢谢,我通常只需要登录.basicConfig()就可以了,但我想这是有意义的,
log = logging.getLogger(__file__)
def func():
print "1"
log.debug("Printed")
g = gevent.spawn(func)
g.join()
但是当我运行它时,我的日志不会显示在shell中。有什么想法吗?是否有更好的方法在基于gevent的协同程序中进行日志记录?它与gevent无关。您应该配置,例如
谢谢,我通常只需要登录.basicConfig()就可以了,但我想这是有意义的,因为它将lvl设置为NOTSET。
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(msg)s")