#!/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..')
网友评论