import logging logging.basicConfig(format="%(asctime)s:%(name)s:%(levelname)s:%(message)s",filename=‘web_server.log‘,level=logging.DEBUG) #logging.basicConfig(format=‘%(asctime)s %(message)s‘,filename=‘web_server.log‘,level=logging.DEBUG) logging.warning(‘is when this event was logged.‘) #logging.basicConfig(filename=‘web_server.log‘ , format=‘%(levelname)s %s(acstime)s %(message)s‘,level=logging.DEBUG) logging.warning(‘warning log‘) logging.debug(‘debug log‘) logging.info(‘info log‘) logging.error(‘error log‘) logging.critical(‘critical log‘)
原文:https://www.cnblogs.com/zy09/p/13626607.html