All notes
Logging

logging

Logging.

Good example


import logging

logger = logging.getLogger('wcf')
logger.setLevel(logging.INFO)

# Console
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
fh = logging.FileHandler('/tmp/spam.log')
fh.setLevel(logging.INFO)

# Formatter
fm = logging.Formatter('%(levelname)s %(asctime)s. %(filename)s:%(lineno)d - %(message)s')

ch.setFormatter(fm)
logger.addHandler(ch)

logger.debug("")
logger.info("")
logger.warning("")
logger.error("")
logger.critical("")

# General method
logger.log(logging.INFO, "")
# This method should only be called from an exception handler:
logger.exception("")

Level and its Numeric value: