【发布时间】:2015-02-01 22:31:50
【问题描述】:
我有一个尝试添加日志记录的 Python pgm。它正在记录,但没有为每个条目添加时间戳。我已经研究过它,阅读了文档等,它看起来正确地写给了我,但它没有给我时间戳。这里有什么不正确的地方?
lfname = "TestAPIlog.log"
logging.basicConfig(filename=lfname, format='%(asctime)s %(message)s',
filemode='w', level=logging.WARNING )
logging.info('Started')
上面产生的日志顶部是这样的:
INFO:root:Started
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.uber.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /v1/estimates/price?end_latitude=39.762239&start_latitude=39.753385&server_token=MY_TOKEN_HERE&start_longitude=-104.998454&end_longitude=-105.013322 HTTP/1.1" 200 None
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.uber.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /v1/estimates/price?
谢谢,
剁
【问题讨论】: