_fg97w
Last Updated: February 25, 2016
·
11.79K
· toumorokoshi
250ce698f19e67da83e2b8a4742ab519

Creating a python logger to stdout

import logging
import sys
log = logging.getLogger(__name__)
out_hdlr = logging.StreamHandler(sys.stdout)
out_hdlr.setFormatter(logging.Formatter('%(asctime)s %(message)s'))
out_hdlr.setLevel(logging.INFO)
log.addHandler(out_hdlr)
log.setLevel(logging.INFO)

Then you can do:

log.debug("NO")
log.error("THIS IS AN ERROR")
Say Thanks
Respond

1 Response
Add your response

13580
6f2bbe2eb0ac6372b554e273deb43326

.ERROR should be .error

over 1 year ago ·