Home  >  Q&A  >  body text

logging - Python log, should the time use UTC time or local time?

Actual Phenomenon

  1. I remember reading a blog before, saying that the time in UTC 0 time zone should be used

  2. But there is nothing wrong with using local time?

Related codes

2017-06-02 10:32:37,951 ERROR concurrent_fetch MainProcess DummyThread-1 concurrent_fetch.py 69 worker err: pision by zero
Traceback (most recent call last):
  File "concurrent_fetch.py", line 67, in worker
    result = 1 / 0
ZeropisionError: pision by zero

Context

代言代言2708 days ago1165

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-06-12 09:28:57

    If you use your own machine, then using local time will definitely be simpler and easier to watch. In fact, even if you collaborate across machines, work in a distributed manner, etc., using local time is not a big problem, as long as you ensure that your local time and The machines you are working on are in the same time zone, so the time difference will not be huge. All machines can check the time through ntp to avoid time confusion

    reply
    0
  • 天蓬老师

    天蓬老师2017-06-12 09:28:57

    • Using local time seems to be more readable, but the characters used in Chinese are relatively long, which naturally takes up more space, especially when there are many records.

    • Using UTC time is more convenient to calculate, but it is not objective in reading, so the size used is naturally smaller.

    reply
    0
  • Cancelreply