Skip to content

Instantly share code, notes, and snippets.

@mickhan
Created December 10, 2015 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickhan/e8c5b7c113168d74abcf to your computer and use it in GitHub Desktop.
Save mickhan/e8c5b7c113168d74abcf to your computer and use it in GitHub Desktop.
配置一个logger
#日志
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
#app handler's log
handler_logger = logging.getLogger('handler')
handler_logger.setLevel(logging.DEBUG)
handler_fh = logging.FileHandler(log_dir+'/handler.log')
handler_fh.setLevel(logging.DEBUG)
handler_fh.setFormatter(formatter)
handler_logger.addHandler(handler_fh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment