Python Logging Module logging timestamp to include microsecond

后端 未结 4 1726
猫巷女王i
猫巷女王i 2021-01-01 18:21

I am using python\'s logging module for logs, but needed the timestamp to include microsecond. It seems the timestamp can only get as precise as millisecond. Here\'s my test

4条回答
  •  再見小時候
    2021-01-01 19:01

    Just completing @Luo_Hongshuai answer for python 3.7 :

    format=%(asctime)s.%(msecs)06f
    datefmt=%Y-%m-%d %H:%M:%S
    

提交回复
热议问题