Python 以自定义时间格式登录

Python 以自定义时间格式登录,python,python-2.7,Python,Python 2.7,日志模块在日志消息旁边提供自动关闭显示信息: logging.basicConfig(format='%(levelname)s {%(filename)s:%(lineno)s} in %(funcName)s: %(message)s', level=logging.DEBUG) 我想包括从脚本运行时开始的秒数。日志记录模块提供了毫秒,但如何将启动后的秒数包含在此格式字符串中?中: 我想要秒,而不是毫秒,毫秒提供相同的功能。 relativeCreated %(relativeCreate

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

logging.basicConfig(format='%(levelname)s {%(filename)s:%(lineno)s} in %(funcName)s: %(message)s', level=logging.DEBUG)
我想包括从脚本运行时开始的秒数。日志记录模块提供了毫秒,但如何将启动后的秒数包含在此格式字符串中?

中:


我想要秒,而不是毫秒,毫秒提供相同的功能。
relativeCreated %(relativeCreated)d 

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