import logging logging basicConfig level logging DEBUG logging getLogg

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> l = logging.getLogger('foo')
>>> l.handlers
[]
>>> l.addHandler(logging.FileHandler('/tmp/f'))
>>> l.handlers
[<logging.FileHandler instance at 0xb7dc318c>]
>>> l.handlers[0].setLevel(logging.DEBUG)
>>> l.debug('x')
DEBUG:foo:x