美文网首页
python 日志

python 日志

作者: Joncc | 来源:发表于2019-05-13 11:28 被阅读0次
    #!/usr/bin/env python
    #-*- coding: utf-8 -*-
    import logging
    LOG_PATH="/var/log/my.log"
    LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
    DATE_FORMAT = "%m/%d/%Y %H:%M:%S %p"
    logging.basicConfig(filename=LOG_PATH, level=logging.DEBUG, format=LOG_FORMAT, datefmt=DATE_FORMAT)
    logs = logging.getLogger(__name__)
    
    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.")
    
    logs.info("2222222, this log")
    

    简单的

    import logging
    logging.basicConfig(filename='./rest_logger.log', filemode='a', level=logging.INFO)
    logs = logging.getLogger()
    logs.info('logs..')
    

    相关文章

      网友评论

          本文标题:python 日志

          本文链接:https://www.haomeiwen.com/subject/lcllaqtx.html