登录自定义时间格式

时间:2016-01-05 21:46:37

标签: python python-2.7

日志记录模块在日志消息旁边提供自动显示关闭信息:

logging.basicConfig(format='%(levelname)s {%(filename)s:%(lineno)s} in %(funcName)s: %(message)s', level=logging.DEBUG)

我希望包含从脚本运行时开始的秒数。日志记录模块提供msecs但是如何包含自此格式字符串开始以来的秒数?

1 个答案:

答案 0 :(得分:1)

documented logrecord attributes

relativeCreated %(relativeCreated)d 

Time in milliseconds when the LogRecord was created, relative to 
the time the logging module was loaded.