How to use logging inside Gevent?

I have code like:

log = logging.getLogger(__file__)

def func():
    print "1"
    log.debug("Printed")

g = gevent.spawn(func)
g.join()

but when I started it, my log is not displayed in the shell. Any ideas? Is there a better way to log inside geout based coroutines?

+5
source share
1 answer

It is not associated with gevent. You must configure logging, for example,

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(msg)s")
+7
source

All Articles