import logging
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('/var/tmp/myapp.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.WARNING)
logger.error('We have a problem')
logger.info('While this is just chatty')
only error was logged
2003-07-08 16:49:45,896 ERROR We have a problem
No comments:
Post a Comment