Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use logging inside Gevent?

Tags:

python

gevent

I have a code like:

log = logging.getLogger(__file__)

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

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

but when I ran it my log doesn't show in shell. Any ideas? Is there a better way to do logging inside gevent based coroutines?

like image 210
Marconi Avatar asked Sep 27 '11 19:09

Marconi


1 Answers

It is unrelated to gevent. You should configure logging e.g.,

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(msg)s")
like image 78
jfs Avatar answered Oct 31 '22 08:10

jfs