How to set timestamps on GMT/UTC on Python logging? How to set timestamps on GMT/UTC on Python logging? python python

How to set timestamps on GMT/UTC on Python logging?


logging.Formatter.converter = time.gmtime

(documented in the docstring of logging.Formatter.formatTime)


Just setting logging.Formatter.converter = time.gmtime is ineffective for me in Python 2.5.

So I created a child class with it set, and use that in place of logging.Formatter:

class UTCFormatter(logging.Formatter):    converter = time.gmtime