• python logging简单日志记录


    import logging
    LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
    DATE_FORMAT = "%m/%d/%Y %H:%M:%S %p"
    
    logging.basicConfig(filename='my.log', level=logging.DEBUG, format=LOG_FORMAT, datefmt=DATE_FORMAT)
    
    #下面就可以在程序内以以下方式记录入my.log文档内:
    logging.debug("This is a debug log.")
    logging.info("This is a info log.")
    logging.warning("This is a warning log.")
    logging.error("This is a error log.")
    logging.critical("This is a critical log.")
    
    
    输出结果格式:
    05/08/2017 14:29:04 PM - DEBUG - This is a debug log.
    05/08/2017 14:29:04 PM - INFO - This is a info log.
    05/08/2017 14:29:04 PM - WARNING - This is a warning log.
    05/08/2017 14:29:04 PM - ERROR - This is a error log.
    05/08/2017 14:29:04 PM - CRITICAL - This is a critical log.
    
  • 相关阅读:
    leetcode 137
    leetcode 134
    133. Clone Graph
    leetcode 131
    leetcode 130
    mac uwsgi ssl issue handler
    leetcode 85 Maximal Rectangle golang
    leetcode 84 golang
    leetcode 61
    C# 后台实现一次上传多个文件
  • 原文地址:https://www.cnblogs.com/qxh-beijing2016/p/14816548.html
Copyright © 2020-2023  润新知