如何在python中使用具有不同时间戳的日志模块?
我的位置与服务器位置相差3小时,我希望在不更改服务器设置的情况下使我的日志时间与本地时间相同?答案是如何在python中使用具有不同时间戳的日志模块?,python,logging,Python,Logging,我的位置与服务器位置相差3小时,我希望在不更改服务器设置的情况下使我的日志时间与本地时间相同?答案是 import logging import time logging.basicConfig(format='%(asctime)s %(message)s') logging.warning('server time') logging.Formatter.converter = lambda self, current: time.localtime(current-3600*3) l
import logging
import time
logging.basicConfig(format='%(asctime)s %(message)s')
logging.warning('server time')
logging.Formatter.converter = lambda self, current: time.localtime(current-3600*3)
logging.warning('time at your zone')
time.localtime
是服务器时间。然后我给了bias-3600*3(或+是可能的)。可能重复感谢,这正是我需要的。